How can I find out if the C ++ compiler makes streaming static object code?

In GCC, a local static variable is thread safe (using the __cxa_guard_acquire special function) if -fno-threadsafe-statics provided with a compiler option.

Similarly, the MSVC 2015 version and version support the same function and can be disabled using /Zc:threadSafeInit- .

Is there any macro or other functions, such as __EXCEPTIONS or __GXX_RTTI , to check at compile time if such functions are included or not? I think checking __cplusplus or _MSC_VER will not help.

+5
source share
1 answer

There seems to be one definition of __cpp_threadsafe_static_init .

SD-6: recommendations for testing SG10 functions :

C ++ 11 Functions

Significant C ++ 11 Features

Doc. No. Name Primary section Macro name Value heading

N2660 Dynamic initialization and destruction with Concurrency 3.6 __cpp_threadsafe_static_init 200806 predefined

CLang - http://clang.llvm.org/cxx_status.html#ts ( github.com )

GCC - https://gcc.gnu.org/projects/cxx-status.html

MSVC - Feature Request in Research https://developercommunity.visualstudio.com/content/problem/96337/feature-request-cpp-threadsafe-static-init.html

Useful at cppreference.com:

+2
source

Source: https://habr.com/ru/post/1268773/


All Articles