简体   繁体   English

在 .rc 文件中使用预处理器宏

[英]Using Preprocessor Macros in .rc Files

I have a C++ program in Visual Studio Community 2015 where I need to include a different resource for debug and release versions.我在 Visual Studio Community 2015 中有一个 C++ 程序,我需要在其中包含用于调试和发布版本的不同资源。 Debug and release versions are differentiated by defining the _DEBUG macro for the debug version, otherwise leaving it undefined.调试版本和发布版本通过为调试版本定义_DEBUG宏来区分,否则保持未定义。

So naturally I tried to put a #if defined(_DEBUG) into my .rc file, but when compiling the resource compiler acts like the macro isn't defined and compiles it as it was a release version (when it is not).所以很自然地,我尝试将#if defined(_DEBUG)放入我的 .rc 文件中,但是在编译资源时,编译器的行为就像未定义宏一样,并将其编译为发布版本(如果不是)。

How do I make the resource compiler see the macro?如何让资源编译器看到宏?

为了将预处理器定义传递给资源编译器,您还必须在项目设置(配置属性 -> 资源 -> 常规)中定义它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM