tbb function names conflict with MSVC debug heap macros

tbb function names conflict with MSVC debug heap macros

The following .cpp does not compile under Visual Studio in a Debug build:

#define _CRTDBG_MAP_ALLOC
#include
#include

Reason: crtdbg.h provides macros for malloc() and free() that track the file and line number of allocations when linking with the Debug heap (Multithreaded Debug, or Multithreaded Debug DLL). Certain TBB classes have member functions with the same name as the standard C library functions. For example:

class allocate_continuation_proxy { void free(); }

Workaround: undefine free before including certain tbb headers when using the MSVC Debug Heap.

A better solution would be to rename free() in all tbb classes (perhaps "deallocate"?).

1 post / 0 new
For more complete information about compiler optimizations, see our Optimization Notice.