C编译时cmath错误

C编译时cmath错误,c,compiler-errors,visual-studio-2012,cmath,C,Compiler Errors,Visual Studio 2012,Cmath,我已经在这上面呆了很长时间,由于某种原因,我的C代码没有编译。它会产生很多cmath错误 因为将代码和错误放在一起会占用很多空间: #include <stdlib.h> #include <stdio.h> #include <Windows.h> #include <fstream> typedef unsigned char* pointer; void printDbPointers(void); void show_int(int);

我已经在这上面呆了很长时间,由于某种原因,我的C代码没有编译。它会产生很多cmath错误

因为将代码和错误放在一起会占用很多空间:

#include <stdlib.h>
#include <stdio.h>
#include <Windows.h>
#include <fstream>

typedef unsigned char* pointer;

void printDbPointers(void);
void show_int(int);
void show_bytes(unsigned char*, int);
void floatingPointRep();
void fahrenheit();

int main()
{
    int a = 100;
    show_int(a);
    floatingPointRep();
    fahrenheit();
    printDbPointers();
    Sleep(100000);
    return 0;
}

void printDbPointers(){
    char hi[7] = {'t', 'i', 'g', 'e', 'r', '\0'};
    char *p, **dp;

    p = &(hi[0]);
    dp = &p;

    printf("%c %c\n", *p, **dp);
    printf("%p %p %p\n", p, *dp, hi);
    p+=1;
    printf("%c, %c\n", *p, **dp);
    printf("%p %p %p\n", p, *dp, hi);
    *dp+=2;
    printf("%c, %c\n", *p, **dp);
    printf("%p %p %p\n", p, *dp, hi);
}


void show_int(int x)
{
    show_bytes((pointer) &x, sizeof(int));
}

void show_bytes(pointer start, int len)
{
    int i;
    for(i=0;i<len;i++)
    {
        // printf("0x%p\t0x%.2x\n", start + i, start[i]);
        printf("0x%p\t\n", start + i, start[i]);
        printf("\n");
    }
}


void floatingPointRep()
{
    float f1 = 1.0;
    float f2 = 0.0;
    int i;
    for ( i=0; i<10; i++ ) {
        f2 += 1.0/10.0;
    }

    printf("0x%08x 0x%08x\n", *(int*)&f1, *(int*)&f2);
    printf("f1 = %10.8f\n", f1);
    printf("f2 = %10.8f\n\n", f2);

    f1 = 1E30;
    f2 = 1E-30;
}

void fahrenheit()
{
    int i;
    double arr[3] = {12345678.000, 98765345.333, 456793332.300};
    for (i = 0; i < 3; i++)
    printf ("%g\n", arr[i]);
}

似乎有些混乱。你已经包含了FSRANT,这是C++的一部分,而不是C.< PF>由于某种原因,FSUW似乎有自己的CyMaple的包含,错误可能来自C和C++之间的不兼容性。 编辑:


是的,经过几个级别的#includes之后,cmath被#包括在内,而且cmath不仅仅是math.h的副本,还包含特定于C++的代码。

一点也不。这就是这里的奥秘。请参阅上面我的代码链接。似乎有些混乱。你已经包含了FSRATH,但这是C++的一部分,而不是C哦,我明白了。完美的那就行了。我想你可以把这个
fstream
删除,因为代码没有使用它。是的,当然。我最初使用的是一个fstream对象来编写一个函数,我目前在上面的代码中没有这个函数。它没有产生红线,所以我认为fstream没有问题。但这与cmath有什么关系?你可以给我一个详细的答案,这样我就可以接受了
        73  error C1003: error count exceeds 100; stopping compilation  
4   error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath  28  1   
7   error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath  29  1   
11  error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath  30  1   
15  error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath  31  1   
19  error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath  32  1   
23  error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath  33  1   
27  error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath  34  1   
31  error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath  35  1   
34  error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath  37  1   
37  error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath  38  1   
41  error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath  39  1   
45  error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath  40  1   
49  error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath  41  1   
53  error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath  42  1   
57  error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath  43  1   
61  error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath  44  1   
64  error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath  46  1   
66  error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath  48  1   
69  error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath  49  1   
63  error C2061: syntax error : identifier 'abs'    c:\program files\microsoft visual studio 11.0\vc\include\cmath  46  1   
65  error C2061: syntax error : identifier 'acos'   c:\program files\microsoft visual studio 11.0\vc\include\cmath  48  1   
3   error C2061: syntax error : identifier 'acosf'  c:\program files\microsoft visual studio 11.0\vc\include\cmath  28  1   
33  error C2061: syntax error : identifier 'acosl'  c:\program files\microsoft visual studio 11.0\vc\include\cmath  37  1   
67  error C2061: syntax error : identifier 'asin'   c:\program files\microsoft visual studio 11.0\vc\include\cmath  48  1   
5   error C2061: syntax error : identifier 'asinf'  c:\program files\microsoft visual studio 11.0\vc\include\cmath  28  1   
35  error C2061: syntax error : identifier 'asinl'  c:\program files\microsoft visual studio 11.0\vc\include\cmath  37  1   
68  error C2061: syntax error : identifier 'atan'   c:\program files\microsoft visual studio 11.0\vc\include\cmath  49  1   
70  error C2061: syntax error : identifier 'atan2'  c:\program files\microsoft visual studio 11.0\vc\include\cmath  49  1   
8   error C2061: syntax error : identifier 'atan2f' c:\program files\microsoft visual studio 11.0\vc\include\cmath  29  1   
38  error C2061: syntax error : identifier 'atan2l' c:\program files\microsoft visual studio 11.0\vc\include\cmath  38  1   
6   error C2061: syntax error : identifier 'atanf'  c:\program files\microsoft visual studio 11.0\vc\include\cmath  29  1   
36  error C2061: syntax error : identifier 'atanl'  c:\program files\microsoft visual studio 11.0\vc\include\cmath  38  1   
71  error C2061: syntax error : identifier 'ceil'   c:\program files\microsoft visual studio 11.0\vc\include\cmath  49  1   
9   error C2061: syntax error : identifier 'ceilf'  c:\program files\microsoft visual studio 11.0\vc\include\cmath  29  1   
39  error C2061: syntax error : identifier 'ceill'  c:\program files\microsoft visual studio 11.0\vc\include\cmath  38  1   
72  error C2061: syntax error : identifier 'cos'    c:\program files\microsoft visual studio 11.0\vc\include\cmath  50  1   
10  error C2061: syntax error : identifier 'cosf'   c:\program files\microsoft visual studio 11.0\vc\include\cmath  30  1   
12  error C2061: syntax error : identifier 'coshf'  c:\program files\microsoft visual studio 11.0\vc\include\cmath  30  1   
42  error C2061: syntax error : identifier 'coshl'  c:\program files\microsoft visual studio 11.0\vc\include\cmath  39  1   
40  error C2061: syntax error : identifier 'cosl'   c:\program files\microsoft visual studio 11.0\vc\include\cmath  39  1   
13  error C2061: syntax error : identifier 'expf'   c:\program files\microsoft visual studio 11.0\vc\include\cmath  30  1   
43  error C2061: syntax error : identifier 'expl'   c:\program files\microsoft visual studio 11.0\vc\include\cmath  39  1   
14  error C2061: syntax error : identifier 'fabsf'  c:\program files\microsoft visual studio 11.0\vc\include\cmath  31  1   
44  error C2061: syntax error : identifier 'fabsl'  c:\program files\microsoft visual studio 11.0\vc\include\cmath  40  1   
16  error C2061: syntax error : identifier 'floorf' c:\program files\microsoft visual studio 11.0\vc\include\cmath  31  1   
46  error C2061: syntax error : identifier 'floorl' c:\program files\microsoft visual studio 11.0\vc\include\cmath  40  1   
17  error C2061: syntax error : identifier 'fmodf'  c:\program files\microsoft visual studio 11.0\vc\include\cmath  31  1   
47  error C2061: syntax error : identifier 'fmodl'  c:\program files\microsoft visual studio 11.0\vc\include\cmath  40  1   
18  error C2061: syntax error : identifier 'frexpf' c:\program files\microsoft visual studio 11.0\vc\include\cmath  32  1   
48  error C2061: syntax error : identifier 'frexpl' c:\program files\microsoft visual studio 11.0\vc\include\cmath  41  1   
20  error C2061: syntax error : identifier 'ldexpf' c:\program files\microsoft visual studio 11.0\vc\include\cmath  32  1   
50  error C2061: syntax error : identifier 'ldexpl' c:\program files\microsoft visual studio 11.0\vc\include\cmath  41  1   
22  error C2061: syntax error : identifier 'log10f' c:\program files\microsoft visual studio 11.0\vc\include\cmath  33  1   
52  error C2061: syntax error : identifier 'log10l' c:\program files\microsoft visual studio 11.0\vc\include\cmath  42  1   
21  error C2061: syntax error : identifier 'logf'   c:\program files\microsoft visual studio 11.0\vc\include\cmath  32  1   
51  error C2061: syntax error : identifier 'logl'   c:\program files\microsoft visual studio 11.0\vc\include\cmath  41  1   
24  error C2061: syntax error : identifier 'modff'  c:\program files\microsoft visual studio 11.0\vc\include\cmath  33  1   
54  error C2061: syntax error : identifier 'modfl'  c:\program files\microsoft visual studio 11.0\vc\include\cmath  42  1   
25  error C2061: syntax error : identifier 'powf'   c:\program files\microsoft visual studio 11.0\vc\include\cmath  33  1   
55  error C2061: syntax error : identifier 'powl'   c:\program files\microsoft visual studio 11.0\vc\include\cmath  42  1   
26  error C2061: syntax error : identifier 'sinf'   c:\program files\microsoft visual studio 11.0\vc\include\cmath  34  1   
28  error C2061: syntax error : identifier 'sinhf'  c:\program files\microsoft visual studio 11.0\vc\include\cmath  34  1   
58  error C2061: syntax error : identifier 'sinhl'  c:\program files\microsoft visual studio 11.0\vc\include\cmath  43  1   
56  error C2061: syntax error : identifier 'sinl'   c:\program files\microsoft visual studio 11.0\vc\include\cmath  43  1   
29  error C2061: syntax error : identifier 'sqrtf'  c:\program files\microsoft visual studio 11.0\vc\include\cmath  34  1   
59  error C2061: syntax error : identifier 'sqrtl'  c:\program files\microsoft visual studio 11.0\vc\include\cmath  43  1   
30  error C2061: syntax error : identifier 'tanf'   c:\program files\microsoft visual studio 11.0\vc\include\cmath  35  1   
32  error C2061: syntax error : identifier 'tanhf'  c:\program files\microsoft visual studio 11.0\vc\include\cmath  35  1   
62  error C2061: syntax error : identifier 'tanhl'  c:\program files\microsoft visual studio 11.0\vc\include\cmath  44  1   
60  error C2061: syntax error : identifier 'tanl'   c:\program files\microsoft visual studio 11.0\vc\include\cmath  44  1