changeset 4328:ce9284aebd40

new macro ORTHANC_DEPRECATED
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 25 Nov 2020 13:34:58 +0100
parents 9684a690ca63
children 9dc0e42f868b
files OrthancFramework/Resources/CMake/JsonCppConfiguration.cmake OrthancFramework/Sources/Compatibility.h
diffstat 2 files changed, 18 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Resources/CMake/JsonCppConfiguration.cmake	Tue Nov 24 20:53:21 2020 +0100
+++ b/OrthancFramework/Resources/CMake/JsonCppConfiguration.cmake	Wed Nov 25 13:34:58 2020 +0100
@@ -100,9 +100,9 @@
 
   if (CMAKE_COMPILER_IS_GNUCXX)
     message("Switching to C++11 standard in gcc, as version of JsonCpp is >= 1.0.0")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -Wno-deprecated-declarations")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
   elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
     message("Switching to C++11 standard in clang, as version of JsonCpp is >= 1.0.0")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-deprecated-declarations")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
   endif()
 endif()
--- a/OrthancFramework/Sources/Compatibility.h	Tue Nov 24 20:53:21 2020 +0100
+++ b/OrthancFramework/Sources/Compatibility.h	Wed Nov 25 13:34:58 2020 +0100
@@ -33,6 +33,18 @@
 #endif
 
 
+// Macro "ORTHANC_DEPRECATED" tags a function as having been deprecated
+#if __cplusplus >= 201402L   // C++14
+#  define ORTHANC_DEPRECATED [[deprecated]]
+#elif defined(__GNUC__) || defined(__clang__)
+#  define ORTHANC_DEPRECATED __attribute__((deprecated))
+#elif defined(_MSC_VER)
+#  define ORTHANC_DEPRECATED __declspec(deprecated)
+#else
+#  define ORTHANC_DEPRECATED
+#endif
+
+
 // Macros "ORTHANC_OVERRIDE" and "ORTHANC_FINAL" wrap the "override"
 // and "final" keywords introduced in C++11, to do compile-time
 // checking of virtual methods
@@ -43,11 +55,11 @@
 #  error ORTHANC_OVERRIDE_SUPPORTED cannot be defined at this point
 #endif 
 
-#if __cplusplus >= 201103L
+#if __cplusplus >= 201103L   // C++11
 #  define ORTHANC_OVERRIDE_SUPPORTED 1
 #else
 #  ifdef _MSC_VER
-#    if _MSC_VER >= 1600
+#    if _MSC_VER >= 1600  // Visual Studio 2010 (10.0)
 #      define ORTHANC_OVERRIDE_SUPPORTED 1
 #    endif
 #  endif
@@ -84,7 +96,7 @@
 // (or higher). This header file can be made for fine-grained, if required, 
 // based on specific _MSC_VER values
 
-#  if _MSC_VER >= 1600
+#  if _MSC_VER >= 1600  // Visual Studio 2010 (10.0)
 #    define ORTHANC_Cxx03_DETECTED 0
 #  else
 #    define ORTHANC_Cxx03_DETECTED 1
@@ -94,7 +106,7 @@
 // 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
+#  if __cplusplus < 201103L  // C++11
 #    define ORTHANC_Cxx03_DETECTED 1
 #  else
 #    define ORTHANC_Cxx03_DETECTED 0