Hey. The title displays the error and i was just wondering how i could fix it. Thanks!

#include "resource.h"

IDR_MYMENU MENU
BEGIN
    POPUP "&File"
    BEGIN
        MENUITEM "E&xit", ID_FILE_EXIT
    END

    POPUP "&Stuff"
    BEGIN
        MENUITEM "&Go", ID_STUFF_GO
        MENUITEM "G&o somewhere else", 0, GRAYED
    END
END

IDI_MYICON ICON "menu_one.ico"

Dani AI

Generated

Short version: that snippet is a Windows resource script (MENU / ICON blocks), not C++ code. The C++ compiler will see tokens like MENU, POPUP or a numeric ID and complain with "expected , or ; before numeric constant". This is exactly what was pointing out: resource scripts must be compiled by a resource compiler, not the C++ compiler.

Practical fix: move the menu/icon block into a file with a .rc extension (for example project.rc) and add that .rc to the Dev‑C++ project so the IDE invokes the resource compiler. Keep resource.h as a simple list of numeric ID macros (no variable declarations, no stray semicolons). If resource.h accidentally contains C/C++ declarations the resource compiler or the C++ compiler (if the header gets pulled into .cpp) will also fail. A minimal resource.h looks like:

/* resource.h */
#define IDR_MYMENU   101
#define ID_FILE_EXIT 40001
#define ID_STUFF_GO  40002
#define IDI_MYICON   201

How this ties to earlier posts: guessed a missing semicolon — that can be relevant only if resource.h contains non-#define lines. asked to see resource.h: posting that file (exact contents) is the next best diagnostic. is right that Dev‑C++ can build resources, but only when the file is a proper .rc added to the project (Dev‑C++ just calls the resource tool behind the scenes).

Quick checks to try now: 1) Confirm the resource block is not saved inside lolLOLlol.cpp. 2) Rename/move it to *.rc and add that file to the project. 3) Verify resource.h contains only #define lines and no stray punctuation or declarations. If errors persist, post the exact resource.h text and the project file list so the build step that is compiling the .rc (or mistakenly compiling it as .cpp) can be identified.

Recommended Answers

All 9 Replies

you forgot a ";" ^^
at what line does it expect but not find?

c++ compilers don't know how to compile resource files. Use a resource compiler for that.

I'm not sure what language that is, but its not C or C++, unless the contents of "resource.h" happen to be an extremely nasty set of macros and #define statements.

If we knew what was inside resource.h. we might be able to give a better answer

I'm not sure what language that is, but its not C or C++, unless the contents of "resource.h" happen to be an extremely nasty set of macros and #define statements.

If we knew what was inside resource.h. we might be able to give a better answer

That is a resource file that defines MS-Window GUI resources such as menu, dialog boxes, etc. resource.h just contains define's for integers that are used in the resource file and elsewhere in the c++ code. Resource files are compiled with resource compilers, not c++ compilers.

Dev-C++ will compile this. I have done it before. Check your resource.h for any missing semicolons.

Dev-C++ is not a compiler -- its an IDE that calls other programs to compile the files. And there should be no semicolons in resource.h

commented: Totally approved/agreed! +2

1. There could be a missing semicolon in resource.h if he didn't use all #define macros, and declared something like "long something" in it. It would look weird, but there still could be one.

2. Take a look. His error is "3 C:\Dev-Cpp\lolLOLlol.cpp expected `,' or `;' before numeric constant". C:\Dev-Cpp\ is Dev-C++'s default installation directory. That must mean he's using it right? Also, I'm not saying that a C++ compiler could do that. I'm just saying that he must have an error in resource.h or something.

I will agree that resource.h might contain some crap that the resource compiler doesn't understand. Only the op can know that, and he has posted nothing about it. The *.h file could be just missing the // for start of comment. But since we're just guessing, there is no point discussing this any more.

Post your resource.h Code Shark, so we can see if there's anything wrong.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.