diff --git a/kaitai/exceptions.h b/kaitai/exceptions.h index 4d1c85f..589c15e 100644 --- a/kaitai/exceptions.h +++ b/kaitai/exceptions.h @@ -11,7 +11,7 @@ // achieve that: C++98 compilers prefer `throw()`, C++11 and later // use `noexcept`. We define KS_NOEXCEPT macro for that. -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900) +#ifdef KAITAI_STREAM_H_CPP11_SUPPORT #define KS_NOEXCEPT noexcept #else #define KS_NOEXCEPT throw() diff --git a/kaitai/kaitaistream.h b/kaitai/kaitaistream.h index 9934c77..60dab0b 100644 --- a/kaitai/kaitaistream.h +++ b/kaitai/kaitaistream.h @@ -4,6 +4,11 @@ // Kaitai Struct runtime API version: x.y.z = 'xxxyyyzzz' decimal #define KAITAI_STRUCT_VERSION 11000L +// check for C++11 support - https://stackoverflow.com/a/40512515 +#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900) +#define KAITAI_STREAM_H_CPP11_SUPPORT +#endif + #include // int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t #include // std::streamsize @@ -11,7 +16,10 @@ #include // std::numeric_limits #include // std::istringstream #include // std::string + +#ifdef KAITAI_STREAM_H_CPP11_SUPPORT #include // std::enable_if, std::is_integral +#endif namespace kaitai { @@ -229,8 +237,7 @@ class kstream { * since C++11) in older C++ implementations. */ template -// check for C++11 support - https://stackoverflow.com/a/40512515 -#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900) +#ifdef KAITAI_STREAM_H_CPP11_SUPPORT // https://stackoverflow.com/a/27913885 typename std::enable_if< std::is_integral::value &&