C++ REST SDK conflicts with Intel TBB on linux?

Oct 24, 2014 at 6:48 AM
In this simple code,
#include <cpprest/basic_types.h>
#include <tbb/concurrent_hash_map.h>

int main()
{
        return 0;
}
I got following errors:
g++ -std=c++11 -Itbb/include -Icasablanca/Release/include -Iboost -c -o rest_tbb.o rest_tbb.cpp
In file included from rest_tbb.cpp:1:0:
tbb/include/tbb/cache_aligned_allocator.h: In member function ‘void tbb::cache_aligned_allocator<T>::construct(U*, Args&& ...)’:
tbb/include/tbb/cache_aligned_allocator.h:100:30: error: expected type-specifier
     { ::new((void *)p) U(std::forward<Args>(args)...); }
                          ^
casablanca/Release/include/cpprest/basic_types.h:84:22: note: in definition of macro ‘_XPLATSTR’
#define _XPLATSTR(x) x
                  ^
tbb/include/tbb/cache_aligned_allocator.h:100:28: note: in expansion of macro ‘U’
     { ::new((void *)p) U(std::forward<Args>(args)...); }
                        ^
tbb/include/tbb/cache_aligned_allocator.h:100:30: error: expected ‘;’
     { ::new((void *)p) U(std::forward<Args>(args)...); }
                          ^
casablanca/Release/include/cpprest/basic_types.h:84:22: note: in definition of macro ‘_XPLATSTR’
#define _XPLATSTR(x) x
                  ^
tbb/include/tbb/cache_aligned_allocator.h:100:28: note: in expansion of macro ‘U’
     { ::new((void *)p) U(std::forward<Args>(args)...); }
                        ^
tbb/include/tbb/tbb_allocator.h: In member function ‘void tbb::tbb_allocator<T>::construct(U*, Args&& ...)’:
tbb/include/tbb/tbb_allocator.h:119:30: error: expected type-specifier
     { ::new((void *)p) U(std::forward<Args>(args)...); }
                          ^
casablanca/Release/include/cpprest/basic_types.h:84:22: note: in definition of macro ‘_XPLATSTR’
#define _XPLATSTR(x) x
                  ^
tbb/include/tbb/tbb_allocator.h:119:28: note: in expansion of macro ‘U’
     { ::new((void *)p) U(std::forward<Args>(args)...); }
                        ^
tbb/include/tbb/tbb_allocator.h:119:30: error: expected ‘;’
     { ::new((void *)p) U(std::forward<Args>(args)...); }
                          ^
casablanca/Release/include/cpprest/basic_types.h:84:22: note: in definition of macro ‘_XPLATSTR’
#define _XPLATSTR(x) x
                  ^
tbb/include/tbb/tbb_allocator.h:119:28: note: in expansion of macro ‘U’
     { ::new((void *)p) U(std::forward<Args>(args)...); }
                        ^
make: *** [rest_tbb.o] Error 1


Is there anyone who successfully used Intel TBB with C++ REST SDK?

Thanks.
Oct 24, 2014 at 7:06 AM
I managed to compile by moving all TBB include statements prior to the C++ REST SDK header files.
Marked as answer by sunghun on 10/24/2014 at 12:06 AM
Coordinator
Oct 24, 2014 at 6:16 PM
Hi sunghun,

I just wanted to give you a bit of extra explanation of what's going on here. In Casablanca, in order to support different default Unicode string sizes on different platforms, we define a macro _XPLATSTR(X) which will make your string into a wide string on windows, but leave it as a normal string on other platforms. We also define a shorthand for this (since it's quite ugly) as U(X).

Unfortunately, it looks like Intel's TBB does something similar, so you're getting a collision. Your fix should work just fine here; alternatively you can disable the U() macro by adding the macro "_TURN_OFF_PLATFORM_STRING" to your project.

Sincerely,
roschuma