Header files problem in VS2008

S

Siamak Sarmady

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
 
J

Jonathan Wilson

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 ':'
.....
- 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.
 
B

Ben Voigt [C++ MVP]

Siamak said:
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?

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top