From 885cc4cf9a1d5c167e4cbd26c3294d8b1ad400d8 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 25 Jul 2018 16:59:46 +0200 Subject: [PATCH] Build: require C11/C++11 for all operating systems in master. This is in preparation of upgrading our library dependencies, some of which need C++11. We already use C++11 in blender2.8 and for Windows and macOS, so this just affects Linux. On many distributions this will not require any changes, on some install_deps.sh will need to be run again to rebuild libraries. Differential Revision: https://developer.blender.org/D3568 --- CMakeLists.txt | 100 ++--------- build_files/build_environment/install_deps.sh | 41 +---- build_files/cmake/macros.cmake | 158 ------------------ .../cmake/platform/platform_apple_xcode.cmake | 2 +- .../cmake/platform/platform_win32.cmake | 3 - intern/cycles/CMakeLists.txt | 25 --- intern/cycles/util/util_defines.h | 10 +- intern/cycles/util/util_foreach.h | 9 +- intern/cycles/util/util_function.h | 18 +- intern/cycles/util/util_map.h | 27 +-- intern/cycles/util/util_set.h | 32 +--- intern/cycles/util/util_static_assert.h | 22 +-- intern/cycles/util/util_thread.cpp | 8 - intern/cycles/util/util_thread.h | 24 +-- intern/cycles/util/util_vector.h | 4 - .../blender/alembic/intern/abc_customdata.cc | 9 +- source/blender/blenlib/BLI_compiler_compat.h | 6 +- source/blender/depsgraph/CMakeLists.txt | 22 --- .../blender/depsgraph/util/deg_util_foreach.h | 17 +- .../depsgraph/util/deg_util_function.h | 73 -------- 20 files changed, 40 insertions(+), 570 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b018905e4f..f6435316fec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -505,27 +505,6 @@ if(WIN32) set(CPACK_INSTALL_PREFIX ${CMAKE_GENERIC_PROGRAM_FILES}/${}) endif() -# Experimental support of C11 and C++11 -# -# We default options to whatever default standard in the current compiler. -if(APPLE) - set(_c11_init ON) - set(_cxx11_init ON) - set(WITH_C11 ON) - set(WITH_CXX11 ON) -elseif(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "6.0") AND (NOT WITH_CXX11)) - set(_c11_init ON) - set(_cxx11_init ON) -else() - set(_c11_init OFF) - set(_cxx11_init OFF) -endif() - -option(WITH_C11 "Build with C11 standard enabled, for development use only!" ${_c11_init}) -mark_as_advanced(WITH_C11) -option(WITH_CXX11 "Build with C++11 standard enabled, for development use only!" ${_cxx11_init}) -mark_as_advanced(WITH_CXX11) - # Compiler toolchain if(CMAKE_COMPILER_IS_GNUCC) option(WITH_LINKER_GOLD "Use ld.gold linker which is usually faster than ld.bfd" ON) @@ -703,11 +682,8 @@ elseif(WITH_CYCLES OR WITH_OPENIMAGEIO OR WITH_AUDASPACE OR WITH_INTERNATIONAL O WITH_OPENVDB OR WITH_OPENCOLORIO) # Keep enabled else() - # New dependency graph needs either Boost or C++11 for function bindings. - if(NOT WITH_CXX11) - # Enabled but we don't need it - set(WITH_BOOST OFF) - endif() + # Disable boost if not needed. + set(WITH_BOOST OFF) endif() # auto enable openimageio for cycles @@ -764,9 +740,6 @@ if(WITH_BUILDINFO) endif() endif() -TEST_SHARED_PTR_SUPPORT() -TEST_UNORDERED_MAP_SUPPORT() - if(WITH_AUDASPACE) if(WITH_SYSTEM_AUDASPACE) set(AUDASPACE_DEFINITIONS @@ -1362,42 +1335,8 @@ endif() # Configure Ceres if(WITH_LIBMV) - set(CERES_DEFINES) - - if(WITH_CXX11) - # nothing to be done - elseif(SHARED_PTR_FOUND) - if(SHARED_PTR_TR1_MEMORY_HEADER) - list(APPEND CERES_DEFINES -DCERES_TR1_MEMORY_HEADER) - endif() - if(SHARED_PTR_TR1_NAMESPACE) - list(APPEND CERES_DEFINES -DCERES_TR1_SHARED_PTR) - endif() - else() - message(FATAL_ERROR "Ceres: Unable to find shared_ptr.") - endif() - - if(WITH_CXX11) - list(APPEND CERES_DEFINES -DCERES_STD_UNORDERED_MAP) - elseif(HAVE_STD_UNORDERED_MAP_HEADER) - if(HAVE_UNORDERED_MAP_IN_STD_NAMESPACE) - list(APPEND CERES_DEFINES -DCERES_STD_UNORDERED_MAP) - else() - if(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) - list(APPEND CERES_DEFINES -DCERES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE) - else() - list(APPEND CERES_DEFINES -DCERES_NO_UNORDERED_MAP) - message(STATUS "Ceres: Replacing unordered_map/set with map/set (warning: slower!)") - endif() - endif() - else() - if(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) - list(APPEND CERES_DEFINES -DCERES_TR1_UNORDERED_MAP) - else() - list(APPEND CERES_DEFINES -DCERES_NO_UNORDERED_MAP) - message(STATUS "Ceres: Replacing unordered_map/set with map/set (warning: slower!)") - endif() - endif() + # We always have C++11 which includes unordered_map. + set(CERES_DEFINES -DCERES_STD_UNORDERED_MAP) endif() #----------------------------------------------------------------------------- @@ -1619,28 +1558,17 @@ if(WITH_PYTHON) endif() endif() -if(WITH_CXX11) - if( - CMAKE_COMPILER_IS_GNUCC OR - CMAKE_C_COMPILER_ID MATCHES "Clang" OR - CMAKE_C_COMPILER_ID MATCHES "Intel" - ) - # TODO(sergey): Do we want c++11 or gnu-c++11 here? - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - elseif(MSVC) - # Nothing special is needed, C++11 features are available by default. - else() - message(FATAL_ERROR "Compiler ${CMAKE_C_COMPILER_ID} is not supported for C++11 build yet") - endif() +if( + CMAKE_COMPILER_IS_GNUCC OR + CMAKE_C_COMPILER_ID MATCHES "Clang" OR + CMAKE_C_COMPILER_ID MATCHES "Intel" +) + # TODO(sergey): Do we want c++11 or gnu-c++11 here? + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +elseif(MSVC) + # Nothing special is needed, C++11 features are available by default. else() - # GCC-6 switched to C++11 by default, which would break linking with existing libraries - # by default. So we explicitly disable C++11 for a new GCC so no linking issues happens. - if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "6.0")) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++98") - # We also disable any of C++11 ABI from usage, so we wouldn't even try to - # link to stuff from std::__cxx11 namespace. - add_definitions("-D_GLIBCXX_USE_CXX11_ABI=0") - endif() + message(FATAL_ERROR "Unknown compiler ${CMAKE_C_COMPILER_ID}, can't enable C++11 build") endif() # Visual Studio has all standards it supports available by default diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index 6cd725494b3..8d277ac787e 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -290,7 +290,7 @@ SUDO="sudo" NO_BUILD=false NO_CONFIRM=false -USE_CXX11=false +USE_CXX11=true PYTHON_VERSION="3.6.2" PYTHON_VERSION_MIN="3.6" @@ -501,9 +501,6 @@ while true; do --no-confirm) NO_CONFIRM=true; shift; continue ;; - --use-cxx11) - USE_CXX11=true; shift; continue - ;; --with-all) WITH_ALL=true; shift; continue ;; @@ -802,20 +799,10 @@ OPENCOLLADA_REPO_BRANCH="master" FFMPEG_SOURCE=( "http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2" ) +# C++11 is required now CXXFLAGS_BACK=$CXXFLAGS -if [ "$USE_CXX11" = true ]; then - WARNING "You are trying to use c++11, this *should* go smoothely with any very recent distribution -However, if you are experiencing linking errors (also when building Blender itself), please try the following: - * Re-run this script with '--build-all --force-all' options. - * Ensure your gcc version is at the very least 4.8, if possible you should really rather use gcc-5.1 or above. - -Please note that until the transition to C++11-built libraries if completed in your distribution, situation will -remain fuzzy and incompatibilities may happen..." - PRINT "" - PRINT "" - CXXFLAGS="$CXXFLAGS -std=c++11" - export CXXFLAGS -fi +CXXFLAGS="$CXXFLAGS -std=c++11" +export CXXFLAGS #### Show Dependencies #### @@ -1690,9 +1677,7 @@ compile_OIIO() { # fi cmake_d="$cmake_d -D USE_OCIO=OFF" - if [ "$USE_CXX11" = true ]; then - cmake_d="$cmake_d -D OIIO_BUILD_CPP11=ON" - fi + cmake_d="$cmake_d -D OIIO_BUILD_CPP11=ON" if file /bin/cp | grep -q '32-bit'; then cflags="-fPIC -m32 -march=i686" @@ -1905,9 +1890,7 @@ compile_OSL() { cmake_d="$cmake_d -D OSL_BUILD_PLUGINS=OFF" cmake_d="$cmake_d -D OSL_BUILD_TESTS=OFF" cmake_d="$cmake_d -D USE_SIMD=sse2" - if [ "$USE_CXX11" = true ]; then - cmake_d="$cmake_d -D OSL_BUILD_CPP11=1" - fi + cmake_d="$cmake_d -D OSL_BUILD_CPP11=1" #~ cmake_d="$cmake_d -D ILMBASE_VERSION=$ILMBASE_VERSION" @@ -2293,12 +2276,6 @@ compile_ALEMBIC() { cmake_d="-D CMAKE_INSTALL_PREFIX=$_inst" - # Without Boost or TR1, Alembic requires C++11. - if [ "$USE_CXX11" != true ]; then - cmake_d="$cmake_d -D ALEMBIC_LIB_USES_BOOST=ON" - cmake_d="$cmake_d -D ALEMBIC_LIB_USES_TR1=OFF" - fi - if [ -d $INST/boost ]; then if [ -d $INST/boost ]; then cmake_d="$cmake_d -D BOOST_ROOT=$INST/boost" @@ -4235,12 +4212,6 @@ print_info() { _buildargs="$_buildargs -U *OPENCOLORIO* -U *OPENEXR* -U *OPENIMAGEIO* -U *LLVM* -U *CYCLES*" _buildargs="$_buildargs -U *OPENSUBDIV* -U *OPENVDB* -U *COLLADA* -U *FFMPEG* -U *ALEMBIC*" - if [ "$USE_CXX11" = true ]; then - _1="-D WITH_CXX11=ON" - PRINT " $_1" - _buildargs="$_buildargs $_1" - fi - _1="-D WITH_CODEC_SNDFILE=ON" PRINT " $_1" _buildargs="$_buildargs $_1" diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 5d5425a9fc6..54a41f95819 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -859,164 +859,6 @@ macro(message_first_run) endif() endmacro() -macro(TEST_UNORDERED_MAP_SUPPORT) - # - Detect unordered_map availability - # Test if a valid implementation of unordered_map exists - # and define the include path - # This module defines - # HAVE_UNORDERED_MAP, whether unordered_map implementation was found - # - # HAVE_STD_UNORDERED_MAP_HEADER, was found - # HAVE_UNORDERED_MAP_IN_STD_NAMESPACE, unordered_map is in namespace std - # HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE, unordered_map is in namespace std::tr1 - # - # UNORDERED_MAP_INCLUDE_PREFIX, include path prefix for unordered_map, if found - # UNORDERED_MAP_NAMESPACE, namespace for unordered_map, if found - - include(CheckIncludeFileCXX) - - # Workaround for newer GCC (6.x+) where C++11 was enabled by default, which lead us - # to a situation when there is include but which can't be used uless - # C++11 is enabled. - if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "6.0") AND (NOT WITH_CXX11)) - set(HAVE_STD_UNORDERED_MAP_HEADER False) - else() - CHECK_INCLUDE_FILE_CXX("unordered_map" HAVE_STD_UNORDERED_MAP_HEADER) - endif() - if(HAVE_STD_UNORDERED_MAP_HEADER) - # Even so we've found unordered_map header file it doesn't - # mean unordered_map and unordered_set will be declared in - # std namespace. - # - # Namely, MSVC 2008 have unordered_map header which declares - # unordered_map class in std::tr1 namespace. In order to support - # this, we do extra check to see which exactly namespace is - # to be used. - - include(CheckCXXSourceCompiles) - CHECK_CXX_SOURCE_COMPILES("#include - int main() { - std::unordered_map map; - return 0; - }" - HAVE_UNORDERED_MAP_IN_STD_NAMESPACE) - if(HAVE_UNORDERED_MAP_IN_STD_NAMESPACE) - message_first_run(STATUS "Found unordered_map/set in std namespace.") - - set(HAVE_UNORDERED_MAP "TRUE") - set(UNORDERED_MAP_INCLUDE_PREFIX "") - set(UNORDERED_MAP_NAMESPACE "std") - else() - CHECK_CXX_SOURCE_COMPILES("#include - int main() { - std::tr1::unordered_map map; - return 0; - }" - HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) - if(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) - message_first_run(STATUS "Found unordered_map/set in std::tr1 namespace.") - - set(HAVE_UNORDERED_MAP "TRUE") - set(UNORDERED_MAP_INCLUDE_PREFIX "") - set(UNORDERED_MAP_NAMESPACE "std::tr1") - else() - message_first_run(STATUS "Found but cannot find either std::unordered_map " - "or std::tr1::unordered_map.") - endif() - endif() - else() - CHECK_INCLUDE_FILE_CXX("tr1/unordered_map" HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) - if(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) - message_first_run(STATUS "Found unordered_map/set in std::tr1 namespace.") - - set(HAVE_UNORDERED_MAP "TRUE") - set(UNORDERED_MAP_INCLUDE_PREFIX "tr1") - set(UNORDERED_MAP_NAMESPACE "std::tr1") - else() - message_first_run(STATUS "Unable to find or . ") - endif() - endif() -endmacro() - -macro(TEST_SHARED_PTR_SUPPORT) - # This check are coming from Ceres library. - # - # Find shared pointer header and namespace. - # - # This module defines the following variables: - # - # SHARED_PTR_FOUND: TRUE if shared_ptr found. - # SHARED_PTR_TR1_MEMORY_HEADER: True if header is to be used - # for the shared_ptr object, otherwise use . - # SHARED_PTR_TR1_NAMESPACE: TRUE if shared_ptr is defined in std::tr1 namespace, - # otherwise it's assumed to be defined in std namespace. - - include(CheckIncludeFileCXX) - include(CheckCXXSourceCompiles) - set(SHARED_PTR_FOUND FALSE) - # Workaround for newer GCC (6.x+) where C++11 was enabled by default, which lead us - # to a situation when there is include but which can't be used uless - # C++11 is enabled. - if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "6.0") AND (NOT WITH_CXX11)) - set(HAVE_STD_MEMORY_HEADER False) - else() - CHECK_INCLUDE_FILE_CXX(memory HAVE_STD_MEMORY_HEADER) - endif() - if(HAVE_STD_MEMORY_HEADER) - # Finding the memory header doesn't mean that shared_ptr is in std - # namespace. - # - # In particular, MSVC 2008 has shared_ptr declared in std::tr1. In - # order to support this, we do an extra check to see which namespace - # should be used. - CHECK_CXX_SOURCE_COMPILES("#include - int main() { - std::shared_ptr int_ptr; - return 0; - }" - HAVE_SHARED_PTR_IN_STD_NAMESPACE) - - if(HAVE_SHARED_PTR_IN_STD_NAMESPACE) - message_first_run("-- Found shared_ptr in std namespace using header.") - set(SHARED_PTR_FOUND TRUE) - else() - CHECK_CXX_SOURCE_COMPILES("#include - int main() { - std::tr1::shared_ptr int_ptr; - return 0; - }" - HAVE_SHARED_PTR_IN_TR1_NAMESPACE) - if(HAVE_SHARED_PTR_IN_TR1_NAMESPACE) - message_first_run("-- Found shared_ptr in std::tr1 namespace using header.") - set(SHARED_PTR_TR1_NAMESPACE TRUE) - set(SHARED_PTR_FOUND TRUE) - endif() - endif() - endif() - - if(NOT SHARED_PTR_FOUND) - # Further, gcc defines shared_ptr in std::tr1 namespace and - # is to be included for this. And what makes things - # even more tricky is that gcc does have header, so - # all the checks above wouldn't find shared_ptr. - CHECK_INCLUDE_FILE_CXX("tr1/memory" HAVE_TR1_MEMORY_HEADER) - if(HAVE_TR1_MEMORY_HEADER) - CHECK_CXX_SOURCE_COMPILES("#include - int main() { - std::tr1::shared_ptr int_ptr; - return 0; - }" - HAVE_SHARED_PTR_IN_TR1_NAMESPACE_FROM_TR1_MEMORY_HEADER) - if(HAVE_SHARED_PTR_IN_TR1_NAMESPACE_FROM_TR1_MEMORY_HEADER) - message_first_run("-- Found shared_ptr in std::tr1 namespace using header.") - set(SHARED_PTR_TR1_MEMORY_HEADER TRUE) - set(SHARED_PTR_TR1_NAMESPACE TRUE) - set(SHARED_PTR_FOUND TRUE) - endif() - endif() - endif() -endmacro() - # when we have warnings as errors applied globally this # needs to be removed for some external libs which we dont maintain. diff --git a/build_files/cmake/platform/platform_apple_xcode.cmake b/build_files/cmake/platform/platform_apple_xcode.cmake index 1b8e13a0623..7af69c092cc 100644 --- a/build_files/cmake/platform/platform_apple_xcode.cmake +++ b/build_files/cmake/platform/platform_apple_xcode.cmake @@ -104,7 +104,7 @@ endif() # 10.9 is our min. target, if you use higher sdk, weak linking happens if(CMAKE_OSX_DEPLOYMENT_TARGET) if(${CMAKE_OSX_DEPLOYMENT_TARGET} VERSION_LESS 10.9) - message(STATUS "Setting deployment target to 10.9, lower versions are incompatible with WITH_CXX11") + message(STATUS "Setting deployment target to 10.9, lower versions are not supported") set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "" FORCE) endif() else() diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake index df96333e9f1..bfbc8d90859 100644 --- a/build_files/cmake/platform/platform_win32.cmake +++ b/build_files/cmake/platform/platform_win32.cmake @@ -131,9 +131,6 @@ include(InstallRequiredSystemLibraries) remove_cc_flag("/MDd" "/MD") if(MSVC_CLANG) # Clangs version of cl doesn't support all flags - if(NOT WITH_CXX11) # C++11 is on by default in clang-cl and can't be turned off, if c++11 is not enabled in blender repress some c++11 related warnings. - set(CXX_WARN_FLAGS "-Wno-inconsistent-missing-override") - endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_WARN_FLAGS} /nologo /J /Gd /EHsc -Wno-unused-command-line-argument -Wno-microsoft-enum-forward-reference ") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /nologo /J /Gd -Wno-unused-command-line-argument -Wno-microsoft-enum-forward-reference") else() diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt index 0740aa51039..00ac8e7e182 100644 --- a/intern/cycles/CMakeLists.txt +++ b/intern/cycles/CMakeLists.txt @@ -224,31 +224,6 @@ endif() # TODO(sergey): Consider removing it, only causes confusion in interface. set(WITH_CYCLES_DEVICE_MULTI TRUE) -if(CYCLES_STANDALONE_REPOSITORY) - TEST_UNORDERED_MAP_SUPPORT() -endif() -if(WITH_CXX11) - add_definitions(-DCYCLES_STD_UNORDERED_MAP) -elseif(HAVE_STD_UNORDERED_MAP_HEADER) - if(HAVE_UNORDERED_MAP_IN_STD_NAMESPACE) - add_definitions(-DCYCLES_STD_UNORDERED_MAP) - else() - if(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) - add_definitions(-DCYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE) - else() - add_definitions(-DCYCLES_NO_UNORDERED_MAP) - message(STATUS "Replacing unordered_map/set with map/set (warning: slower!)") - endif() - endif() -else() - if(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) - add_definitions(-DCYCLES_TR1_UNORDERED_MAP) - else() - add_definitions(-DCYCLES_NO_UNORDERED_MAP) - message(STATUS "Replacing unordered_map/set with map/set (warning: slower!)") - endif() -endif() - # Logging capabilities using GLog library. if(WITH_CYCLES_LOGGING) add_definitions(-DWITH_CYCLES_LOGGING) diff --git a/intern/cycles/util/util_defines.h b/intern/cycles/util/util_defines.h index d994d4e08f4..1a09f659eb1 100644 --- a/intern/cycles/util/util_defines.h +++ b/intern/cycles/util/util_defines.h @@ -87,18 +87,10 @@ # define UNLIKELY(x) (x) #endif -#if defined(__cplusplus) && ((__cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER >= 1800)) -# define HAS_CPP11_FEATURES -#endif - #if defined(__GNUC__) || defined(__clang__) -# if defined(HAS_CPP11_FEATURES) /* Some magic to be sure we don't have reference in the type. */ template static inline T decltype_helper(T x) { return x; } -# define TYPEOF(x) decltype(decltype_helper(x)) -# else -# define TYPEOF(x) typeof(x) -# endif +# define TYPEOF(x) decltype(decltype_helper(x)) #endif /* Causes warning: diff --git a/intern/cycles/util/util_foreach.h b/intern/cycles/util/util_foreach.h index 03fcefc67b9..2a74ff0a55d 100644 --- a/intern/cycles/util/util_foreach.h +++ b/intern/cycles/util/util_foreach.h @@ -17,13 +17,8 @@ #ifndef __UTIL_FOREACH_H__ #define __UTIL_FOREACH_H__ -/* Use Boost to get nice foreach() loops for STL data structures. */ +/* Nice foreach() loops for STL data structures. */ -#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) -# define foreach(x, y) for(x : y) -#else -# include -# define foreach BOOST_FOREACH -#endif +#define foreach(x, y) for(x : y) #endif /* __UTIL_FOREACH_H__ */ diff --git a/intern/cycles/util/util_function.h b/intern/cycles/util/util_function.h index 958f8b4008c..f3cc00329ad 100644 --- a/intern/cycles/util/util_function.h +++ b/intern/cycles/util/util_function.h @@ -17,18 +17,12 @@ #ifndef __UTIL_FUNCTION_H__ #define __UTIL_FUNCTION_H__ -#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) -# include -#else -# include -# include -#endif +#include CCL_NAMESPACE_BEGIN -#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) -# define function_bind std::bind -# define function_null nullptr +#define function_bind std::bind +#define function_null nullptr using std::function; using std::placeholders::_1; using std::placeholders::_2; @@ -39,11 +33,7 @@ using std::placeholders::_6; using std::placeholders::_7; using std::placeholders::_8; using std::placeholders::_9; -#else -using boost::function; -# define function_bind boost::bind -# define function_null NULL -#endif + CCL_NAMESPACE_END #endif /* __UTIL_FUNCTION_H__ */ diff --git a/intern/cycles/util/util_map.h b/intern/cycles/util/util_map.h index b3d887f093c..3c9288417cf 100644 --- a/intern/cycles/util/util_map.h +++ b/intern/cycles/util/util_map.h @@ -18,38 +18,13 @@ #define __UTIL_MAP_H__ #include - -#if defined(CYCLES_TR1_UNORDERED_MAP) -# include -#endif - -#if defined(CYCLES_STD_UNORDERED_MAP) || defined(CYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE) -# include -#endif - -#if !defined(CYCLES_NO_UNORDERED_MAP) && !defined(CYCLES_TR1_UNORDERED_MAP) && \ - !defined(CYCLES_STD_UNORDERED_MAP) && !defined(CYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE) // NOLINT -# error One of: CYCLES_NO_UNORDERED_MAP, CYCLES_TR1_UNORDERED_MAP,\ - CYCLES_STD_UNORDERED_MAP, CYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE must be defined! // NOLINT -#endif - +#include CCL_NAMESPACE_BEGIN using std::map; using std::pair; - -#if defined(CYCLES_NO_UNORDERED_MAP) -typedef std::map unordered_map; -#endif - -#if defined(CYCLES_TR1_UNORDERED_MAP) || defined(CYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE) -using std::tr1::unordered_map; -#endif - -#if defined(CYCLES_STD_UNORDERED_MAP) using std::unordered_map; -#endif CCL_NAMESPACE_END diff --git a/intern/cycles/util/util_set.h b/intern/cycles/util/util_set.h index 1d010e19996..298e1f7729a 100644 --- a/intern/cycles/util/util_set.h +++ b/intern/cycles/util/util_set.h @@ -18,24 +18,7 @@ #define __UTIL_SET_H__ #include -#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) -# include -#else -# if defined(CYCLES_TR1_UNORDERED_MAP) -# include -# endif -# if defined(CYCLES_STD_UNORDERED_MAP) || \ - defined(CYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE) -# include -# endif -# if !defined(CYCLES_NO_UNORDERED_MAP) && \ - !defined(CYCLES_TR1_UNORDERED_MAP) && \ - !defined(CYCLES_STD_UNORDERED_MAP) && \ - !defined(CYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE) -# error One of: CYCLES_NO_UNORDERED_MAP, CYCLES_TR1_UNORDERED_MAP,\ - CYCLES_STD_UNORDERED_MAP, CYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE must be defined! // NOLINT -# endif -#endif +#include #if defined(_MSC_VER) && (_MSC_VER >= 1900) # include @@ -44,19 +27,8 @@ CCL_NAMESPACE_BEGIN using std::set; -#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) using std::unordered_set; -#else -# if defined(CYCLES_NO_UNORDERED_MAP) -typedef std::set unordered_set; -# endif -# if defined(CYCLES_TR1_UNORDERED_MAP) || defined(CYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE) -using std::tr1::unordered_set; -# endif -# if defined(CYCLES_STD_UNORDERED_MAP) -using std::unordered_set; -# endif -#endif + CCL_NAMESPACE_END #endif /* __UTIL_SET_H__ */ diff --git a/intern/cycles/util/util_static_assert.h b/intern/cycles/util/util_static_assert.h index e90049254de..dc3cb3f6ecc 100644 --- a/intern/cycles/util/util_static_assert.h +++ b/intern/cycles/util/util_static_assert.h @@ -22,27 +22,7 @@ CCL_NAMESPACE_BEGIN /* TODO(sergey): In theory CUDA might work with own static assert * implementation since it's just pure C++. */ -#ifndef __KERNEL_GPU__ -# if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) -/* C++11 has built-in static_assert() */ -# elif defined(static_assert) -/* Some platforms might have static_assert() defined even tho their - * C++ support wouldn't be declared to be C++11. - */ -# else /* C++11 or MSVC2015 */ -template class StaticAssertFailure; -template <> class StaticAssertFailure {}; -# define _static_assert_private_glue_impl(A, B) A ## B -# define _static_assert_glue(A, B) _static_assert_private_glue_impl(A, B) -# ifdef __COUNTER__ -# define static_assert(condition, message) \ - enum {_static_assert_glue(q_static_assert_result, __COUNTER__) = sizeof(StaticAssertFailure)} // NOLINT -# else /* __COUNTER__ */ -# define static_assert(condition, message) \ - enum {_static_assert_glue(q_static_assert_result, __LINE__) = sizeof(StaticAssertFailure)} // NOLINT -# endif /* __COUNTER__ */ -# endif /* C++11 or MSVC2015 */ -#else /* __KERNEL_GPU__ */ +#ifdef __KERNEL_GPU__ # ifndef static_assert # define static_assert(statement, message) # endif diff --git a/intern/cycles/util/util_thread.cpp b/intern/cycles/util/util_thread.cpp index c66aa484264..16a8591a8a9 100644 --- a/intern/cycles/util/util_thread.cpp +++ b/intern/cycles/util/util_thread.cpp @@ -26,11 +26,7 @@ thread::thread(function run_cb, int group) joined_(false), group_(group) { -#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) thread_ = std::thread(&thread::run, this); -#else - pthread_create(&pthread_id_, NULL, run, (void*)this); -#endif } thread::~thread() @@ -64,7 +60,6 @@ void *thread::run(void *arg) bool thread::join() { joined_ = true; -#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) try { thread_.join(); return true; @@ -72,9 +67,6 @@ bool thread::join() catch (const std::system_error&) { return false; } -#else - return pthread_join(pthread_id_, NULL) == 0; -#endif } CCL_NAMESPACE_END diff --git a/intern/cycles/util/util_thread.h b/intern/cycles/util/util_thread.h index 77b51d37ea0..f39fcfb4279 100644 --- a/intern/cycles/util/util_thread.h +++ b/intern/cycles/util/util_thread.h @@ -17,15 +17,10 @@ #ifndef __UTIL_THREAD_H__ #define __UTIL_THREAD_H__ -#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) -# include -# include -# include -# include -#else -# include -# include -#endif +#include +#include +#include +#include #include #ifdef _WIN32 @@ -42,16 +37,9 @@ CCL_NAMESPACE_BEGIN -#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) typedef std::mutex thread_mutex; typedef std::unique_lock thread_scoped_lock; typedef std::condition_variable thread_condition_variable; -#else -/* use boost for mutexes */ -typedef boost::mutex thread_mutex; -typedef boost::mutex::scoped_lock thread_scoped_lock; -typedef boost::condition_variable thread_condition_variable; -#endif /* own pthread based implementation, to avoid boost version conflicts with * dynamically loaded blender plugins */ @@ -66,11 +54,7 @@ public: protected: function run_cb_; -#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) std::thread thread_; -#else - pthread_t pthread_id_; -#endif bool joined_; int group_; }; diff --git a/intern/cycles/util/util_vector.h b/intern/cycles/util/util_vector.h index 569f503b66e..0b33221ad4d 100644 --- a/intern/cycles/util/util_vector.h +++ b/intern/cycles/util/util_vector.h @@ -59,11 +59,7 @@ public: void shrink_to_fit(void) { -#if __cplusplus < 201103L - vector().swap(*this); -#else std::vector::shrink_to_fit(); -#endif } void free_memory(void) diff --git a/source/blender/alembic/intern/abc_customdata.cc b/source/blender/alembic/intern/abc_customdata.cc index 87545007870..f2ae1c831d1 100644 --- a/source/blender/alembic/intern/abc_customdata.cc +++ b/source/blender/alembic/intern/abc_customdata.cc @@ -26,14 +26,7 @@ #include #include - -#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1900) #include -typedef std::unordered_map uv_index_map; -#else -#include -typedef std::map uv_index_map; -#endif extern "C" { #include "DNA_customdata_types.h" @@ -60,6 +53,8 @@ using Alembic::AbcGeom::OV2fGeomParam; using Alembic::AbcGeom::OC4fGeomParam; +typedef std::unordered_map uv_index_map; + static inline uint64_t uv_to_hash_key(Imath::V2f v) { /* Convert -0.0f to 0.0f, so bitwise comparison works. */ diff --git a/source/blender/blenlib/BLI_compiler_compat.h b/source/blender/blenlib/BLI_compiler_compat.h index 0726e3bb343..2b53975a106 100644 --- a/source/blender/blenlib/BLI_compiler_compat.h +++ b/source/blender/blenlib/BLI_compiler_compat.h @@ -32,11 +32,7 @@ # define alloca _alloca #endif -#if defined(__cplusplus) && ((__cplusplus >= 201103L) || defined(_MSC_VER)) -# define HAS_CPP11_FEATURES -#endif - -#if (defined(__GNUC__) || defined(__clang__)) && defined(HAS_CPP11_FEATURES) +#if (defined(__GNUC__) || defined(__clang__)) && defined(__cplusplus) extern "C++" { /* Some magic to be sure we don't have reference in the type. */ template static inline T decltype_helper(T x) { return x; } diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt index 50c0910ef02..ced045e9e2f 100644 --- a/source/blender/depsgraph/CMakeLists.txt +++ b/source/blender/depsgraph/CMakeLists.txt @@ -100,28 +100,6 @@ set(SRC util/deg_util_function.h ) -if(WITH_CXX11) - add_definitions(-DDEG_STD_UNORDERED_MAP) -elseif(HAVE_STD_UNORDERED_MAP_HEADER) - if(HAVE_UNORDERED_MAP_IN_STD_NAMESPACE) - add_definitions(-DDEG_STD_UNORDERED_MAP) - else() - if(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) - add_definitions(-DDEG_STD_UNORDERED_MAP_IN_TR1_NAMESPACE) - else() - add_definitions(-DDEG_NO_UNORDERED_MAP) - message(STATUS "Replacing unordered_map/set with map/set (warning: slower!)") - endif() - endif() -else() - if(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) - add_definitions(-DDEG_TR1_UNORDERED_MAP) - else() - add_definitions(-DDEG_NO_UNORDERED_MAP) - message(STATUS "Replacing unordered_map/set with map/set (warning: slower!)") - endif() -endif() - if(WITH_LEGACY_DEPSGRAPH) add_definitions(-DWITH_LEGACY_DEPSGRAPH) endif() diff --git a/source/blender/depsgraph/util/deg_util_foreach.h b/source/blender/depsgraph/util/deg_util_foreach.h index cb7361fc708..5484192207b 100644 --- a/source/blender/depsgraph/util/deg_util_foreach.h +++ b/source/blender/depsgraph/util/deg_util_foreach.h @@ -30,19 +30,4 @@ #pragma once -#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) -# define foreach(x, y) for(x : y) -#elif defined(HAVE_BOOST_FUNCTION_BINDINGS) -# include -# define foreach BOOST_FOREACH -#else -#pragma message("No available foreach() implementation. Using stub instead, disabling new depsgraph") - -#ifndef WITH_LEGACY_DEPSGRAPH -# error "Unable to build new depsgraph and legacy one is disabled." -#endif - -#define DISABLE_NEW_DEPSGRAPH - -# define foreach(x, y) for (x; false; (void)y) -#endif +#define foreach(x, y) for(x : y) diff --git a/source/blender/depsgraph/util/deg_util_function.h b/source/blender/depsgraph/util/deg_util_function.h index 38e753ce925..8863d92eb74 100644 --- a/source/blender/depsgraph/util/deg_util_function.h +++ b/source/blender/depsgraph/util/deg_util_function.h @@ -30,81 +30,8 @@ #pragma once -#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1900) - #include using std::function; using namespace std::placeholders; #define function_bind std::bind - -#elif defined(HAVE_BOOST_FUNCTION_BINDINGS) - -#include -#include - -using boost::function; -#define function_bind boost::bind - -#else - -#pragma message("No available function binding implementation. Using stub instead, disabling new depsgraph") - -#ifndef WITH_LEGACY_DEPSGRAPH -# error "Unable to build new depsgraph and legacy one is disabled." -#endif - -#define DISABLE_NEW_DEPSGRAPH - -#include "BLI_utildefines.h" -#include - -template -class function { -public: - function() {}; - function(void *) {} - operator bool() const { return false; } - bool operator== (void *) { return false; } - - template - void operator() (T1) { - BLI_assert(!"Should not be used"); - } -}; - -class Wrap { -public: - Wrap() {} - template - Wrap(T /*arg*/) {} -}; - -template -void *function_bind(T func, - Wrap arg1 = Wrap(), - Wrap arg2 = Wrap(), - Wrap arg3 = Wrap(), - Wrap arg4 = Wrap(), - Wrap arg5 = Wrap(), - Wrap arg6 = Wrap(), - Wrap arg7 = Wrap()) -{ - BLI_assert(!"Should not be used"); - (void)func; - (void)arg1; - (void)arg2; - (void)arg3; - (void)arg4; - (void)arg5; - (void)arg6; - (void)arg7; - return NULL; -} - -#define _1 Wrap() -#define _2 Wrap() -#define _3 Wrap() -#define _4 Wrap() - -#endif