Skip to main content
gamedev.net
🔒 Locked

old code compile errors

Started by Mortizar 3 replies 850+ views
Original Post
Mortizar
Mortizar
Ok this may have been asked befor but i couldn't find it though a search. I moved some old code to a new project and i get compile errors from some ms headers. I am using Visual Studio 2005 and the errors i get are:


c:\program files\microsoft visual studio 8\vc\platformsdk\include\commctrl.h(4026) : error C2059: syntax error : 'constant'
c:\program files\microsoft visual studio 8\vc\platformsdk\include\commctrl.h(4026) : error C2238: unexpected token(s) preceding ';'
c:\program files\microsoft visual studio 8\vc\platformsdk\include\commctrl.h(4027) : error C2059: syntax error : 'constant'
c:\program files\microsoft visual studio 8\vc\platformsdk\include\commctrl.h(4027) : error C2238: unexpected token(s) preceding ';'
c:\program files\microsoft visual studio 8\vc\platformsdk\include\commctrl.h(4028) : error C2059: syntax error : 'constant'
c:\program files\microsoft visual studio 8\vc\platformsdk\include\commctrl.h(4028) : error C2238: unexpected token(s) preceding ';'
c:\program files\microsoft visual studio 8\vc\platformsdk\include\commctrl.h(4029) : error C2059: syntax error : 'constant'
c:\program files\microsoft visual studio 8\vc\platformsdk\include\commctrl.h(4029) : error C2238: unexpected token(s) preceding ';'


any clue as to what could be causeing this? The code worked with VS 6.
LessBread
LessBread
The keyword is 'const' not 'constant'.

You could add

#define constant const

before including that header file.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
NUCLEAR RABBIT
NUCLEAR RABBIT
Quote:
Original post by LessBread
The keyword is 'const' not 'constant'.

You could add

#define constant const

before including that header file.


couldnt of said it better myself [lol]
yadango
yadango
actually, doing something like this "class object { something so(12); };" generates a similar error. looking at those 4 lines in commctrl.h (4026-4029), i see UINT Left; UINT Top; UINT Right; and UINT Bottom;. Do you have any macros defined for Left, Top, Right, and/or Bottom before you include commctrl.h?
Zahlman
Zahlman
LessBread, 'constant' never was the keyword, and apparently this code "used to" work... IIRC, this error means that there is a constant (i.e. an integer, character or string literal) in a place that's unexpected by the grammar.

I think yadango hit it: if you had some other source file with #define Top 0, for example (defining bounds of some screen rectangle), and you include the commctrl.h header after that, then the line becomes "UINT 0;", which at top level makes no sense.

This is one of the many reasons you should not use #defines for constant values, but (ironically enough) const identifiers.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.