#ifdef & #if defined() in resource files

Why do #ifdef and #if defined always return false in resource files? I was going to use these to create different language builds based on the build type, and each build type defines a macro for is language, such as DEBUG, RELEASE_ENGLISH, and RELEASE_FRENCH.

For instance:
1
2
3
4
#define THIS_IS_A_TEST
#ifdef THIS_IS_A_TEST
#error error
#endif 
This works (produces the error) in the resources file, but is completely useless.

1
2
3
#ifdef DEBUG
#error error
#endif 
Will not work (does not produce the error) even in the Debug build which is set to define the DEBUG macro. This code works in all source files and header files but not the resources file.

Is there some setting I have to turn on or some workaround? I have seen this used in other projects and SDKs and templates, etc, so I don't know why it won't work here. I use Visual C++ 2008 Express Edition and am not (can not) use any resource editor - I just edit it in text format.
Last edited on
They shouldn't! The resource compiler understands the same set of directives as the compiler.

Have you set the preprocessor definitions for the resource compiler as well as the compiler?

Andy

Oops...yes that was exactly the problem. I had to set the builds to define the preprocessor macros under the resources as well. Thanks!
Topic archived. No new replies allowed.