expected unqualified-id before numeric constant

May 20, 2019 at 4:48pm
I am following this tutorial page:
http://www.winprog.org/tutorial/menus.html

But in Eclipse I am getting the error:
resource.h:1:20: error: expected unqualified-id before numeric constant
#define IDR_MYMENU 101

What does this mean, and what can I do about it?
May 20, 2019 at 5:15pm
Post the full error text. The actual error probably occurs elsewhere, when the macro is expanded. (You're not trying to compile the .rc file as a .cpp file, are you?)
Last edited on May 20, 2019 at 5:16pm
May 20, 2019 at 6:43pm
Have you included resource.h twice in the same .cpp file?
May 20, 2019 at 9:18pm
@Dutch
I actually tried to compile the .rc as a .cpp file.
There is kind of a solution on
https://www.eclipse.org/forums/index.php/t/80633/
But adding the path to the Tool Settings | MinGW C++ Linker | Miscellaneous | Other Objects is giving me an error. Without this path my project is compiling, but the code from the resource.rc is not working runtime. How to proceed now?
Last edited on May 20, 2019 at 10:18pm
May 21, 2019 at 1:01am
.rc files are compiled by a "resource compiler" program, not the C++ compiler. The standard resource compiler supplied by MS is called RC. I think that MinGW (which I think you are using) has a program called windres.

In Eclipse, there should be a "pre-build" step where you can add the call to windres. Also you need to add the "object" file that's created by windres to the linker, which I guess is what that "other objects" stuff is about.

The windres call will be something like this:
windres -i..\resources.rc -o..\resources.o
I don't know what relative path to use ( ..\ is just an example).
Topic archived. No new replies allowed.