• 15
• 15
• 11
• 9
• 10

# Is The MS C++ Compiler Stupid?

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

## 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 on other sites
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 on other sites
Quote:
 Original post by jpetrieThe 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 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.