现在的位置: 首页 > 综合 > 正文

rc资源文件的宏定义

2012年09月29日 ⁄ 综合 ⁄ 共 822字 ⁄ 字号 评论关闭

遇到一个问题,我希望在 DEBUG模式下包含资源A, 在RELEASE模式下包含B

于是我在 rc文件中写道:

 #ifdef _DEBUG

.................A

#else

................B

#endif 编译后发现

_DEBUG 没有被定义.  

原因:  MS编译器中资源是单独编译的,

在Project + properties, Resources, General, Preprocessor definitions 中可以定义预定义变量,

我们只要在DEBUG模式下写入 _DEBUG就可以了. 详细的参考资料: http://forums.msdn.microsoft.com/zh-CN/vcgeneral/thread/9cdaa780-cc97-498b-815e-cf23c3f3b333/

其中写道:

VS2005 doesn't properly pass the preprocessor definitions for the resource compiler. 

It generates extra double-quotes, fatally confusing rc.exe. 

I got the httpd project to compile by specifying the command line options by hand: Project + properties, Resources, General, Preprocessor definitions = blankProject + properties,     

Project + properties,  Resources, General, Command line, Additional options = /d _DEBUG /d APP_FILE /d BIN_NAME="httpd.exe" /d LONG_NAME="Apache HTTP Server" /d ICON_FILE="apache.ico" /d _VC80_UPGRADE=0x0600

抱歉!评论已关闭.