Jump to content
  • Advertisement
Sign in to follow this  
NickGravelyn

Is The MS C++ Compiler Stupid?

This topic is 3981 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I brought over some real basic C++ code (that Vector class and others I've been working on) so I could work on it on my much faster PC. So I bring over the code files, create a new project for a static library, and get all the boost libraries linked and stuff, go to compile and get this:
1>Matrix.cpp
1>d:\island\src\matrix.cpp(160) : error C2059: syntax error : ')'
1>d:\island\src\matrix.cpp(161) : error C2059: syntax error : '/'
1>d:\island\src\matrix.cpp(175) : error C2059: syntax error : ')'
1>d:\island\src\matrix.cpp(176) : error C2059: syntax error : '/'
1>d:\island\src\matrix.cpp(184) : error C2059: syntax error : '<='
1>d:\island\src\matrix.cpp(186) : error C2059: syntax error : '<='
1>d:\island\src\matrix.cpp(188) : error C2059: syntax error : '<='
1>d:\island\src\matrix.cpp(193) : error C2059: syntax error : ')'
1>d:\island\src\matrix.cpp(194) : error C2059: syntax error : ')'
1>d:\island\src\matrix.cpp(195) : error C2059: syntax error : '/'
1>d:\island\src\matrix.cpp(196) : error C2059: syntax error : ')'
1>d:\island\src\matrix.cpp(206) : error C2059: syntax error : '<='
1>d:\island\src\matrix.cpp(208) : error C2059: syntax error : '<='
1>d:\island\src\matrix.cpp(210) : error C2059: syntax error : '<='
1>d:\island\src\matrix.cpp(217) : error C2059: syntax error : '/'
1>d:\island\src\matrix.cpp(218) : error C2059: syntax error : ')'
1>d:\island\src\matrix.cpp(226) : error C2059: syntax error : '<='
1>d:\island\src\matrix.cpp(228) : error C2059: syntax error : '<='
1>d:\island\src\matrix.cpp(230) : error C2059: syntax error : '<='
1>d:\island\src\matrix.cpp(235) : error C2059: syntax error : ')'
1>d:\island\src\matrix.cpp(237) : error C2059: syntax error : ')'
1>d:\island\src\matrix.cpp(239) : error C2059: syntax error : '/'
1>d:\island\src\matrix.cpp(240) : error C2059: syntax error : ')'


Now, I won't post up those lines, but needless to say those are basic syntax errors it's reporting. Funny thing is that my code compiles error free using GCC on OS X. So what is causing this? I'm including <math.h> if that matters at all. I tried wrapping that in extern "C" {} but it didn't help. Any other ideas? Edit: I "solved" the problem. I removed two includes from a header file because I didn't need them. They were <windows.h> and <GL/gl.h>. No more errors. If anyone knows why those headers would cause all those errors, I'd still be interested.

Share this post


Link to post
Share on other sites
Advertisement
The GL headers must be included (before|after) the Windows headers. I forget which, but if you do it wrong, weird things happen, because the GL headers depend upon or redefine certain types and macros, et cetera.

It's also possible there was a macro or some such in scope via one of those headers that messed with your code, as the errors seem relatively benign especially for the GL/windows include order, which usually appears to generate errors with types and not punctuation.

Share this post


Link to post
Share on other sites
Quote:
Original post by jpetrie
The GL headers must be included (before|after) the Windows headers. I forget which, but if you do it wrong, weird things happen, because the GL headers depend upon or redefine certain types and macros, et cetera.


windows.h comes first, for exactly that reason.

Share this post


Link to post
Share on other sites
Often can be helpful to run cl /P to examine the preprocessed output, that should give you an idea of what the code looks like post macro expansion.

Share this post


Link to post
Share on other sites
Could be you need to #define NOMINMAX before including windows.h - there's min and max macros defined in there that can cause a bunch of compile errors in code that uses min and max functions as I'd guess your vector library might.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!