在调试模式下使用英特尔 TBB

Using Intel TBB in debug mode

我正在尝试使用英特尔线程构建模块调试 C++ 代码,使用我在此处找到的过程 Debugging in threading building Blocks。 我的问题与下面这句话有关。

Be sure to compile with the macro TBB_USE_DEBUG set to 1 so that TBB's checking will be enabled.

我添加了宏#define TBB_USE_DEBUG 1 在我的主要功能的开头。但是,在编译时我收到以下警告

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

因此我的两个问题:

您必须将 #define 放在 之前,您包括来自 TBB 库的任何内容。特别是,确保它位于源文件或头文件中可能存在的任何 #include <tbb> 之前。

根据错误文本,定义被插入到包含之后。意思是,它很可能没有任何效果,因为

  • 定义仅在先前包含的 headers
  • 中计算
  • 或者因为 main-function 以外的其他来源看不到宏

解决这个问题

  • 首选:将所有 source-files 的定义设置为 compiler-parameter。那往往就是-D参数
  • 或在所有源中的任何包含之前设置定义。通常由委派 header.

我不知道如何测试调试是否处于活动状态,因为我不知道 TBB。