VS ignores symbol _Debug in Resources.rc (Visual Studio bug ?)

…衆ロ難τιáo~ 提交于 2021-01-28 19:49:26

问题


Can anybody explain me that very strange fenomenon ?

In my VS2005 Managed C++ project file (VCPROJ) is defined:

<Configuration
    Name="Debug|Win32"
    ....
    PreprocessorDefinitions="WIN32;_DEBUG"
    ....
</Configuration>
<Configuration
    Name="Release|Win32"
    ....
    PreprocessorDefinitions="WIN32;NDEBUG"
    ....
</Configuration>

Whereever I used the symbol _Debug it works perfect. For example:

#ifdef _DEBUG
    #include "noexist.h"
#endif

produces an error

C1083: Cannot open include file: 'noexist.h': No such file or directory

when compiled as Debug while it compiles without error as Release.

OK.

Now comes that strange thing: The symbol _DEBUG is completely ignored in the file Resources.rc. Although Visual Studio itself inserts these lines:

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 1,0,0,1
 PRODUCTVERSION 1,0,0,1
 FILEFLAGSMASK 0x17L
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x4L
 FILETYPE 0x2L
 FILESUBTYPE 0x0L
etc...

the flag _DEBUG (and also NDEBUG) do not exist in Resources.rc.

If I insert the same lines

#ifdef _DEBUG
    #include "noexist.h"
#endif

into Resources.rc it does neither produce an error compiled as Debug nor as Release!

The same applies to

#ifdef NDEBUG
    #include "noexist.h"
#endif

which compiles without error as Release and as Debug!

How is that possible ? How can a global compiler symbol be present in one file but not in another file ?

Is this a Visual Studio bug ?

(In pure C++ projects this works fine, this problem is only in my Managed C++ project)

Is there a workaround ?

来源:https://stackoverflow.com/questions/16850863/vs-ignores-symbol-debug-in-resources-rc-visual-studio-bug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!