问题
I am trying to debug a C++ code using Intel Thread Building Blocks, with the procedure I have found here Debugging in threading building Blocks. My question is related to the following sentence.
Be sure to compile with the macro TBB_USE_DEBUG set to 1 so that TBB's checking will be enabled.
I have added the macro #define TBB_USE_DEBUG 1
at the beginning of my main function. However, when compiling I get the following warning
warning: "TBB_USE_DEBUG" redefined
#define TBB_USE_DEBUG 1
/usr/include/tbb/tbb_config.h:287:0: note: this is the location of the previous definition
#define TBB_USE_DEBUG 0
Hence my two questions:
- Did I put the macro at the good place ?
- How can I check that my code indeed linked with the debug library ?
回答1:
According to errortext, the define was inserted after includes. Meaning, it is very probably without any effect, because
- the define is evaluated only in previously included headers
- or because sources other than your main-function do not see the macro
To fix this
- preferred: set the define for all source-files as compiler-parameter. That is often the
-D
parameter - or set the define before any includes in ALL sources. Often done by a delegating header.
I dont know how to test whether debug is active, as i dont know TBB.
回答2:
You have to put the #define
before you include anything from the TBB library. In particular, make sure it comes before any #include <tbb>
that may be in your source or header files.
来源:https://stackoverflow.com/questions/50136667/using-intel-tbb-in-debug-mode