Mason Wheeler
Mason Wheeler

Reputation: 84550

How to deal with "Illegal macro definition in command line or defines page" error?

I'm trying to embed a certain text file as a resource in my EXE, and I'm having a heck of a time of it.

I made a simple one-line .rc file and added it to the project, but BRCC32 chokes on it with a completely unhelpful error:

[BRCC32 Error] MyRes.rc(1): Fatal error Illegal macro definition in command line or defines page.

Here's the contents of the file, in its entirety:

DATA_BASIC_ORDER     RCDATA Data\Data_BasicOrder.txt

This only happens if I build in the IDE. I'm able to successfully build a .RES file from this on the command line, and opening it in a hex editor shows both the resource name and the contents of the text file, but if I link it in with a {$R} directive, the resource doesn't show up in the EXE. I verified it with ResHacker; the resource just isn't there. So something very strange is going on.

I have tried shutting down and restarting the IDE. No change. I also opened the .rc file in a hex editor to make sure that there are no weird characters messing things up, but no, it's a plain ANSI text file.

Does anyone have any idea what's going on with this and how I can fix it?

EDIT: It keeps getting weirder. If I leave the file line completely blank, I still get the same error. But if I remove the file from the project, (removing it from the listing in the Project Explorer,) that error message goes away, but it's still not showing up in the build.

Upvotes: 0

Views: 1037

Answers (3)

sbayli
sbayli

Reputation: 101

I had the same error message and it kept pointing to MyResource.rc even though the problem was in one of the Conditional Defines. Somehow two different defines ended up on the same line separated by a comma. PHNOCODE,DECODE After correcting the Defines my project builds properly.

Upvotes: 0

Stijn Sanders
Stijn Sanders

Reputation: 36840

As the error message denotes, the answer to your problem may be visible in the command line for the call to the BRCC32.exe tool made by the compiler.

I ran into this error by trying to add a number of extra 'Conditional defines' in the compiler configuration. I suspect there's a limit to the number and the length (and/or the number of underscores) allowed for conditional defines that are passed to brcc32 as well (using the -d parameter, apparently)

Upvotes: 0

Nipp
Nipp

Reputation: 103

Backslash look suspicious. Try to quote it:

RCDATA Data\\Data_BasicOrder.txt

Upvotes: 1

Related Questions