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

Was it helpful?

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

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
scroll top