Hello,
I have a simple .c file in VS2008 and I have set the compile type in
(project properties-> C, C++ -> Advanced -> Compile as) to C.
main.c content:
#include <GL/glut.h>
#include <GL/glu.h>
#include <GL/gl.h>
#include <string>
#include <sstream>
#include <assert.h>
int main( int argc, char** argv )
{
return 0;
}
1- Now I am trying to compile the file but I get these errors (more than
100):
Error 1 error C2143: syntax error : missing '{' before ':'
f:\programming\vs9\vc\include\cstdio 39 gl0001
Error 2 error C2059: syntax error : ':'
f:\programming\vs9\vc\include\cstdio 39 gl0001
Error 3 error C2143: syntax error : missing '{' before ':'
f:\programming\vs9\vc\include\cstdio 41 gl0001
Error 4 error C2059: syntax error : ':'
f:\programming\vs9\vc\include\cstdio 41 gl0001
Error 5 error C2143: syntax error : missing '{' before ':'
.....
2- If I change extension and compile type to .cpp I get the following error:
Error 1 error C2381: 'exit' : redefinition; __declspec(noreturn)
differs f:\programming\vs9\vc\include\stdlib.h 371 gl0001
- Could someone kindly tell me the reason of those errors in number 1?
- What about Number 2?
Thanks
Mac
Jonathan Wilson - 26 Apr 2008 12:38 GMT
> 1- Now I am trying to compile the file but I get these errors (more than
> 100):
[quoted text clipped - 10 lines]
> .....
> - Could someone kindly tell me the reason of those errors in number 1?
Your code wont work as a .c file since <string> and <sstream> require a C++
compiler.
Don't know about your other error.
Ben Voigt [C++ MVP] - 28 Apr 2008 15:06 GMT
> Hello,
>
[quoted text clipped - 35 lines]
>
> - Could someone kindly tell me the reason of those errors in number 1?
You can't use the C++ standard library in C code.
> - What about Number 2?
Add #include <stdlib.h> at the top of your program to get the correct
prototype for exit, then the compiler will tell you where in the gl/*
headers exit is declared badly. Or get a better copy of the gl/* headers.
You can post back here the new line that the error occurs on after #include
<stdlib.h> beforehand.
> Thanks
> Mac