Search code examples
c++windowsc-preprocessordebug-symbols

Detect building with symbols in preprocessor on Windows


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

  • 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).