Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / April 2008

Tip: Looking for answers? Try searching our database.

Header files problem in VS2008

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Siamak Sarmady - 26 Apr 2008 12:06 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.