We currently use the Python libraries in Boost and Intel TBB. The libraries in Boost undefine the MSVC macro _DEBUG then subsequently redefine it without any value. In TBB_Config.h the macro TBB_USE_DEBUG is set from the value of _DEBUG. When TBB_USE_DEBUG is later used in #if statements within the same header file the preprocessor cannot evaluate the expression and pre-processing fails.
Looking at the documentation on MSDN the value that _DEBUG is set to isn't stated therefore it shouldn't be assumed the value will be 1. Additionally having _DEBUG set to a value other than 1 may cause inconsistent behaviour too.
Currently the code in TBB_CONFIG.h is:
#ifndef TBB_USE_DEBUG #ifdef _DEBUG #define TBB_USE_DEBUG _DEBUG // This assumes _DEBUG is evaluable #else #define TBB_USE_DEBUG 0 #endif #endif /* TBB_USE_DEBUG */
I propose the following fix:
#define TBB_USE_DEBUG 1 // Should always be evaluable
Sorry for a long response. There are several moments that should be considered. On the one hand, MSDN states that "The compiler defines _DEBUG when you specify the /MTd or /MDd option.", on the other hand, it also states "_DEBUG Defined as 1 when the /LDd, /MDd, or /MTd compiler option is set. Otherwise, undefined." One more aspect is that "_DEBUG = 0" usually supposed to mean "no debug".
The current approach satisfies the following conditions:
- "_DEBUG is undefined" means "no debug"
- "_DEBUG defined to something that is evaluated to 0" means "no debug"
- "_DEBUG defined to something that is evaluated to non-zero value" means "debug"
- "_DEBUG defined to nothing (empty)" causes compile-time error.
The proposed solution solves the bullet #4 but breaks the bullet #2. The both bullets are not covered by MSDN but used by the community, so it does not seem acceptable to break one for the sake of another.
We are working on the solution that supports the bullet #4 as "_DEBUG defined to nothing (empty)" means "debug" but does not break the bullet #2. However, I cannot promise you exact date when it is available in the product. Sorry for inconveniences.