diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f7dbb1..f4482cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,10 +147,11 @@ if(${Boost_VERSION} LESS 104800) # Older Boost versions don't work with C++11 elseif(USE_CXX11) enable_cxx11() - check_cxx11("std::unique_ptr" INNOEXTRACT_HAVE_STD_UNIQUE_PTR) + check_cxx11("alignof" INNOEXTRACT_HAVE_ALIGNOF) if(WIN32) check_cxx11("std::codecvt_utf8_utf16" INNOEXTRACT_HAVE_STD_CODECVT_UTF8_UTF16) endif() + check_cxx11("std::unique_ptr" INNOEXTRACT_HAVE_STD_UNIQUE_PTR) endif() # Don't expose internal symbols to the outside world by default diff --git a/cmake/check-cxx11-alignof.cpp b/cmake/check-cxx11-alignof.cpp new file mode 100644 index 0000000..5fc32da --- /dev/null +++ b/cmake/check-cxx11-alignof.cpp @@ -0,0 +1,3 @@ +int main() { + return alignof(int) != 1; +} \ No newline at end of file diff --git a/src/configure.hpp.in b/src/configure.hpp.in index e77f09a..a5cfcce 100644 --- a/src/configure.hpp.in +++ b/src/configure.hpp.in @@ -26,6 +26,7 @@ #cmakedefine01 INNOEXTRACT_HAVE_BSWAP_64 // C++11 functionality +#cmakedefine01 INNOEXTRACT_HAVE_ALIGNOF #cmakedefine01 INNOEXTRACT_HAVE_STD_CODECVT_UTF8_UTF16 #cmakedefine01 INNOEXTRACT_HAVE_STD_UNIQUE_PTR diff --git a/src/util/types.hpp b/src/util/types.hpp index 746bd0e..f3e2407 100644 --- a/src/util/types.hpp +++ b/src/util/types.hpp @@ -32,6 +32,8 @@ #include "util/util.hpp" +#include "configure.hpp" + namespace util { #if BOOST_VERSION < 104200 @@ -91,7 +93,9 @@ struct compatible_integer { //! Get the alignment of a type. template unsigned int alignment_of() { -#if defined(_MSC_VER) && _MSC_VER >= 1300 +#if INNOEXTRACT_HAVE_ALIGNOF + return alignof(T); +#elif defined(_MSC_VER) && _MSC_VER >= 1300 return __alignof(T); #elif defined(__GNUC__) return __alignof__(T);