i've got to do a bit of pure ANSI C and i'm trying to do it in Visual Studio 2010. Problem is; regardless of setting the compiler to pure C and flipping the \Za compiler switch to disable windows extensions - the code just won't compile:
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
cout << M_PI;
return 0;
}
This is in a file called Test.c - there are no precompiled headers and everything should be fine, but this is what the compiler spits out:
1>ClCompile:
1> Test.c
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(19): error C2061: syntax error : identifier 'acosf'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(19): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(19): error C2061: syntax error : identifier 'asinf'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(19): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(20): error C2061: syntax error : identifier 'atanf'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(20): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(20): error C2061: syntax error : identifier 'atan2f'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(20): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(20): error C2061: syntax error : identifier 'ceilf'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(20): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(21): error C2061: syntax error : identifier 'cosf'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(21): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(21): error C2061: syntax error : identifier 'coshf'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(21): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(21): error C2061: syntax error : identifier 'expf'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(21): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(22): error C2061: syntax error : identifier 'fabsf'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(22): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(22): error C2061: syntax error : identifier 'floorf'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(22): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(22): error C2061: syntax error : identifier 'fmodf'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(22): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(23): error C2061: syntax error : identifier 'frexpf'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(23): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(23): error C2061: syntax error : identifier 'ldexpf'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(23): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(23): error C2061: syntax error : identifier 'logf'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(23): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(24): error C2061: syntax error : identifier 'log10f'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(24): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(24): error C2061: syntax error : identifier 'modff'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(24): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(24): error C2061: syntax error : identifier 'powf'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(24): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(25): error C2061: syntax error : identifier 'sinf'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(25): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(25): error C2061: syntax error : identifier 'sinhf'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(25): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(25): error C2061: syntax error : identifier 'sqrtf'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(25): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(26): error C2061: syntax error : identifier 'tanf'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(26): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(26): error C2061: syntax error : identifier 'tanhf'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(26): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(28): error C2061: syntax error : identifier 'acosl'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(28): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(28): error C2061: syntax error : identifier 'asinl'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(28): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(29): error C2061: syntax error : identifier 'atanl'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(29): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(29): error C2061: syntax error : identifier 'atan2l'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(29): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(29): error C2061: syntax error : identifier 'ceill'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(29): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(30): error C2061: syntax error : identifier 'cosl'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(30): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(30): error C2061: syntax error : identifier 'coshl'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(30): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(30): error C2061: syntax error : identifier 'expl'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(30): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(31): error C2061: syntax error : identifier 'fabsl'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(31): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(31): error C2061: syntax error : identifier 'floorl'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(31): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(31): error C2061: syntax error : identifier 'fmodl'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(31): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(32): error C2061: syntax error : identifier 'frexpl'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(32): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(32): error C2061: syntax error : identifier 'ldexpl'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(32): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(32): error C2061: syntax error : identifier 'logl'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(32): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(33): error C2061: syntax error : identifier 'log10l'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(33): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(33): error C2061: syntax error : identifier 'modfl'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(33): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(33): error C2061: syntax error : identifier 'powl'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(33): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(34): error C2061: syntax error : identifier 'sinl'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(34): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(34): error C2061: syntax error : identifier 'sinhl'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(34): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(34): error C2061: syntax error : identifier 'sqrtl'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(34): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(35): error C2061: syntax error : identifier 'tanl'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(35): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(35): error C2061: syntax error : identifier 'tanhl'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(35): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(37): error C2061: syntax error : identifier 'abs'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(37): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(39): error C2061: syntax error : identifier 'acos'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(39): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(39): error C2061: syntax error : identifier 'asin'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(39): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(40): error C2061: syntax error : identifier 'atan'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(40): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(40): error C2061: syntax error : identifier 'atan2'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(40): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(40): error C2061: syntax error : identifier 'ceil'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(40): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(41): error C2061: syntax error : identifier 'cos'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(41): fatal error C1003: error count exceeds 100; stopping compilation
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.17
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I'm not that experienced with VS and C, but i've looked around and nothing I do seems to work. I'm guessing it'll be something silly. Thanks in advance
(Note: this same error occurs with absolutely no references to any math libraries)