Author Topic: windres.exe not using compiler variables set up in IDE  (Read 4536 times)

Miserableman

  • Guest
windres.exe not using compiler variables set up in IDE
« on: November 11, 2005, 01:12:10 am »
I'm trying to compile a bit of open-source software in Windows using Code::Blocks/MinGW. It's been a bit of a nightmare so far, I don't think anyone's ever tried compiling this software on this platform with this compiler. Anyway, I've got it to the point where it trips up trying to compile the program's resources. The problem, it thinks, is on this line of the resource file:
Code
PUSHBUTTON      "Close",IDCLOSE,172,237,50,14
Specifically, it doesn't like IDCLOSE. On inspection, IDCLOSE is defined in winuser.h, inside a preprocessor block as so:
Code
#if (WINVER >= 0x0400)
#define IDCLOSE 8
#define IDHELP 9
#endif
I have WINVER=0x0500 set up as part of my compiler defines in the IDE, so it seems that the resource compiler windres.exe is not using these definitions (I can see that the code compiler is acknowledging these defines because if I type garbage inside this #if/endif block it bombs out before it ever gets to the resource compilation stage). Indeed, if I replicate the windres.exe call that Code::Blocks is making on the command line, and add the WINVER definition to it, it compiles cleanly. Of course, I don't want to have to drop to the command-line for every compilation that requires the resource compiler to use preprocessor variables. How are you supposed to do this within the Code::Blocks GUI?

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: windres.exe not using compiler variables set up in IDE
« Reply #1 on: November 11, 2005, 10:57:14 am »
You are right that the resource compiler is not passed the compiler defs. Not sure if this is intentional or a bug.

However, in the specific example that you have given, it makes no difference.
windef.h (which is included from windows.h) contains
Code
#ifndef WINVER
#define WINVER 0x0400
#endif
So your example would compile anyway (and it does, I tried).
Assuming that you have set up your compiler system correctly, do you include windows.h or anything from your .rc file?
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Miserableman

  • Guest
Re: windres.exe not using compiler variables set up in IDE
« Reply #2 on: November 11, 2005, 01:44:31 pm »
I'm not at home with the code to be able to tell whether windows.h is included with the resource file, but the preprocessor block was in the middle of a long list of definitions, something like:
Code
#define IDALRIGHT 0
#define IDMAYBE 1
#define IDDIGEREEDOO 2
#define IDDIGEREEDONT 3
#define IDDIGEREECANT 4
#define IDDIGEREEBETTERNOT 5
#define IDYES 6
#define IDNO 7
#if (WINVER >= 0x0400)
#define IDCLOSE 8
#define IDHELP 9
#endif
I tried using one of the other variables in place of IDCLOSE (IDNO I'm pretty sure) and it compiled cleanly.