# HG changeset patch # User Benjamin Golinvaux # Date 1583693482 -3600 # Node ID 0b3aacdf77f5db59ac55d7dc2332a0c9f2c5000f # Parent ae0e3fd609df015f79c2db799ae661c473ebc7ef Fixed C++03 detection support for Visual C++ compilers diff -r ae0e3fd609df -r 0b3aacdf77f5 Core/Compatibility.h --- a/Core/Compatibility.h Wed Mar 04 10:00:42 2020 +0100 +++ b/Core/Compatibility.h Sun Mar 08 19:51:22 2020 +0100 @@ -33,14 +33,27 @@ #pragma once -// __cplusplus cannot be used in Visual C++ versions older than 1914 -#if (defined _MSC_VER) && (_MSC_VER < 1914) -# if _MSC_VER < 1900 +//#define Orthanc_Compatibility_h_STR2(x) #x +//#define Orthanc_Compatibility_h_STR1(x) Orthanc_Compatibility_h_STR2(x) + +//#pragma message("__cplusplus = " Orthanc_Compatibility_h_STR1(__cplusplus)) + +#if (defined _MSC_VER) +//# pragma message("_MSC_VER = " Orthanc_Compatibility_h_STR1(_MSC_VER)) +// The __cplusplus macro cannot be used in Visual C++ < 1914 (VC++ 15.7) +// However, even in recent versions, __cplusplus will only be correct (that is, +// correctly defines the supported C++ version) if a special flag is passed to +// the compiler ("/Zc:__cplusplus") +// To make this header more robust, we use the _MSVC_LANG equivalent macro. +# if (defined _MSVC_LANG) && (_MSVC_LANG >= 201103L) +# define ORTHANC_Cxx03_DETECTED 0 +# else # define ORTHANC_Cxx03_DETECTED 1 -# else -# define ORTHANC_Cxx03_DETECTED 0 # endif #else +// of _MSC_VER is not defined, we assume __cplusplus is correctly defined +// if __cplusplus is not defined (very old compilers??), then the following +// test will compare 0 < 201103L and will be true --> safe. # if __cplusplus < 201103L # define ORTHANC_Cxx03_DETECTED 1 # else @@ -48,8 +61,9 @@ # endif #endif +#if ORTHANC_Cxx03_DETECTED == 1 +//#pragma message("C++ 11 support is not present.") -#if ORTHANC_Cxx03_DETECTED == 1 /** * "std::unique_ptr" was introduced in C++11, and "std::auto_ptr" was * removed in C++17. We emulate "std::auto_ptr" using boost: "The @@ -78,5 +92,7 @@ } }; } - +#else +//# pragma message("C++ 11 support is present.") +# include #endif