When you build the command line for cl.exe, if you decide to pass /Zi
(or whatever option you're using for pdb generation), also pass -D_SYMBOLS_GENERATED
. Then, in the code, just use #if defined(_SYMBOLS_GENERATED)
.
Detect building with symbols in preprocessor on Windows
-
09-07-2023 - |
Question
Is there any way to detect when compilation is happening with debugging symbols enabled with the preprocessor? (when using cl.exe)
(Background: Our compile will fail due to toolchain .pdb size limitations, so I'd like to #error earlier rather than have the compile/link fail after a lengthy build.)
Solution
OTHER TIPS
The simplest I can think of is:
#ifdef _DEBUG
#error "no debug builds, sorry"
#endif
It is possible to have _DEBUG defined but not be creating .pdbs, but somehow I doubt you guys are doing that.
The preprocessor reference is available at http://msdn.microsoft.com/en-us/library/y4skk93w.aspx
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow