Using Intel TBB in debug mode

狂风中的少年 提交于 2020-01-15 04:56:09

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!