Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

wanting2learn

macrumors newbie
Original poster
Aug 19, 2010
13
0
If I do this in my header file:

Code:
#define WM_USER 0x0400;
const UINT MSGID_FIRST	= WM_USER + 1;

I get the error:
error: expected ':' before numeric constant


Why is this and how can I solve it?


Thanks
 
In this example, think of the C preprocessor as a mechanism for doing a kind of "search and replace" within the source file.

What do you get when you simulate what the C preprocessor does by manually substituting the definition of WM_USER in that line of code?
 
thanks

if I do this:
const UINT MSGID_FIRST = 0x0400 + 1;

Then it does not give an error.
So I'm thinking that its somethig to do with the #define not giving a type to WM_USER, so I tried:

const UINT WM_USER = 0x0400;
const UINT MSGID_FIRST = WM_USER + 1;

But then it gave me the following error on the same line:
error: initializer element is not constant

So I'm out of ideas sorry,

Thanks for your help.
 
thanks

Sorry my friend,
it was the ';' at the end :eek:,

how embarrassing lol

Thanks again for your help
 
Sorry my friend,
it was the ';' at the end :eek:,

how embarrassing lol

Thanks again for your help

Don't be embarrassed -- it's an easy mistake to make :D

Many programmers prefer to constants or enumerated values instead of #define's -- and in so doing improve the maintainability and debug-ability of their code.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.