diff OrthancFramework/Sources/Compatibility.h @ 4202:2007ab69ac16

moving ORTHANC_FORCE_INLINE and ORTHANC_OVERRIDE from Enumerations.h to Compatibility.h
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 17 Sep 2020 08:35:11 +0200
parents bf7b9edf6b81
children ce9284aebd40
line wrap: on
line diff
--- a/OrthancFramework/Sources/Compatibility.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/Compatibility.h	Thu Sep 17 08:35:11 2020 +0200
@@ -22,6 +22,50 @@
 
 #pragma once
 
+
+// Macro "ORTHANC_FORCE_INLINE" forces a function/method to be inlined
+#if defined(_MSC_VER)
+#  define ORTHANC_FORCE_INLINE __forceinline
+#elif defined(__GNUC__) || defined(__clang__) || defined(__EMSCRIPTEN__)
+#  define ORTHANC_FORCE_INLINE inline __attribute((always_inline))
+#else
+#  error Please support your compiler here
+#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
+// The __cplusplus macro is broken in Visual Studio up to 15.6 and, in
+// later versions, require the usage of the /Zc:__cplusplus flag
+// We thus use an alternate way of checking for 'override' support
+#ifdef ORTHANC_OVERRIDE_SUPPORTED
+#  error ORTHANC_OVERRIDE_SUPPORTED cannot be defined at this point
+#endif 
+
+#if __cplusplus >= 201103L
+#  define ORTHANC_OVERRIDE_SUPPORTED 1
+#else
+#  ifdef _MSC_VER
+#    if _MSC_VER >= 1600
+#      define ORTHANC_OVERRIDE_SUPPORTED 1
+#    endif
+#  endif
+#endif
+
+
+#if ORTHANC_OVERRIDE_SUPPORTED
+// The override keyword (C++11) is enabled
+#  define ORTHANC_OVERRIDE  override 
+#  define ORTHANC_FINAL     final
+#else
+// The override keyword (C++11) is not available
+#  define ORTHANC_OVERRIDE
+#  define ORTHANC_FINAL
+#endif
+
+
+
 //#define Orthanc_Compatibility_h_STR2(x) #x
 //#define Orthanc_Compatibility_h_STR1(x) Orthanc_Compatibility_h_STR2(x)