1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0028439: Configuration - compilation error when using thread_local within XCode 7 or earlier

__has_feature(cxx_thread_local) check has been added
for using thread_local keyword within CLang.
This commit is contained in:
kgv 2017-02-09 15:52:59 +03:00 committed by apn
parent c4fa1c2c62
commit dace4784d1
2 changed files with 16 additions and 7 deletions

View File

@ -122,7 +122,10 @@ if(MINGW)
add_definitions(-D_WIN32_WINNT=0x0501) add_definitions(-D_WIN32_WINNT=0x0501)
# workaround bugs in mingw with vtable export # workaround bugs in mingw with vtable export
set (CMAKE_SHARED_LINKER_FLAGS "-Wl,--export-all-symbols") set (CMAKE_SHARED_LINKER_FLAGS "-Wl,--export-all-symbols")
elseif (DEFINED CMAKE_COMPILER_IS_GNUCXX OR "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xClang") elseif ("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xClang")
# CLang can be used with both libstdc++ and libc++, however on OS X libstdc++ is outdated.
set (CMAKE_CXX_FLAGS "-std=c++0x -stdlib=libc++ ${CMAKE_CXX_FLAGS}")
elseif (DEFINED CMAKE_COMPILER_IS_GNUCXX)
set (CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}") set (CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}")
endif() endif()

View File

@ -58,12 +58,18 @@ static void deallocate_message(Standard_CString aMessage)
} }
} }
// Define Standard_THREADLOCAL modifier as C++11 thread_local keyword // Define Standard_THREADLOCAL modifier as C++11 thread_local keyword where it is available.
// where it is available. #if defined(__clang__)
#if (defined(__INTEL_COMPILER) && __INTEL_COMPILER > 1400) || \ // CLang version: standard CLang > 3.3 or XCode >= 8 (but excluding 32-bit ARM)
(defined(__clang__)) /* assume standard CLang > 3.3 or XCode >= 8 */ || \ // Note: this has to be in separate #if to avoid failure of preprocessor on other platforms
(defined(_MSC_VER) && _MSC_VER >= 1900) /* MSVC++ >= 14 */ || \ #if __has_feature(cxx_thread_local)
(defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) /* GCC >= 4.8 */ #define Standard_THREADLOCAL thread_local
#else
#define Standard_THREADLOCAL
#endif
#elif (defined(__INTEL_COMPILER) && __INTEL_COMPILER > 1400) || \
(defined(_MSC_VER) && _MSC_VER >= 1900) /* MSVC++ >= 14 */ || \
(defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) /* GCC >= 4.8 */
#define Standard_THREADLOCAL thread_local #define Standard_THREADLOCAL thread_local
#else #else
#define Standard_THREADLOCAL #define Standard_THREADLOCAL