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.
Don't be embarrassed -- it's an easy mistake to make 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.