1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
16 //! This file is intended to be the first file included to any
17 //! Open CASCADE source. It defines platform-specific pre-processor
18 //! macros necessary for correct compilation of Open CASCADE code.
20 #ifndef _Standard_Macro_HeaderFile
21 # define _Standard_Macro_HeaderFile
23 //! @def Standard_OVERRIDE
24 //! Should be used in declarations of virtual methods overriden in the
25 //! derived classes, to cause compilation error in the case if that virtual
26 //! function disappears or changes its signature in the base class.
28 //! Expands to C++11 keyword "override" on compilers that are known to
29 //! suppot it; empty in other cases.
30 #if defined(__cplusplus) && (__cplusplus >= 201100L)
31 // part of C++11 standard
32 #define Standard_OVERRIDE override
33 #elif defined(_MSC_VER) && (_MSC_VER >= 1700)
34 // MSVC extension since VS2012
35 #define Standard_OVERRIDE override
37 #define Standard_OVERRIDE
40 //! @def Standard_FALLTHROUGH
41 //! Should be used in a switch statement immediately before a case label,
42 //! if code associated with the previous case label may fall through to that
43 //! next label (i.e. does not end with "break" or "return" etc.).
44 //! This macro indicates that the fall through is intentional and should not be
45 //! diagnosed by a compiler that warns on fallthrough.
47 //! Expands to C++17 attribute statement "[[fallthrough]];" on compilers that
48 //! declare support of C++17, or to "__attribute__((fallthrough));" on
50 #if defined(__cplusplus) && (__cplusplus >= 201703L)
51 // part of C++17 standard
52 #define Standard_FALLTHROUGH [[fallthrough]];
53 #elif defined(__GNUC__) && (__GNUC__ >= 7)
55 #define Standard_FALLTHROUGH __attribute__((fallthrough));
57 #define Standard_FALLTHROUGH
60 //! @def Standard_UNUSED
61 //! Macro for marking variables / functions as possibly unused
62 //! so that compiler will not emit redundant "unused" warnings.
64 //! Expands to "__attribute__((unused))" on GCC and CLang.
65 #if defined(__GNUC__) || defined(__clang__)
66 #define Standard_UNUSED __attribute__((unused))
68 #define Standard_UNUSED
71 //! @def Standard_THREADLOCAL
72 //! Define Standard_THREADLOCAL modifier as C++11 thread_local keyword where it is available.
73 #if defined(__clang__)
74 // CLang version: standard CLang > 3.3 or XCode >= 8 (but excluding 32-bit ARM)
75 // Note: this has to be in separate #if to avoid failure of preprocessor on other platforms
76 #if __has_feature(cxx_thread_local)
77 #define Standard_THREADLOCAL thread_local
79 #elif defined(__INTEL_COMPILER)
80 #if (defined(_MSC_VER) && _MSC_VER >= 1900 && __INTEL_COMPILER > 1400)
81 // requires msvcrt vc14+ (Visual Studio 2015+)
82 #define Standard_THREADLOCAL thread_local
83 #elif (!defined(_MSC_VER) && __INTEL_COMPILER > 1500)
84 #define Standard_THREADLOCAL thread_local
86 #elif (defined(_MSC_VER) && _MSC_VER >= 1900)
87 // msvcrt coming with vc14+ (VS2015+)
88 #define Standard_THREADLOCAL thread_local
89 #elif (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))
91 #define Standard_THREADLOCAL thread_local
94 #ifndef Standard_THREADLOCAL
95 #define Standard_THREADLOCAL
98 //! @def Standard_DEPRECATED("message")
99 //! Can be used in declaration of a method or a class to mark it as deprecated.
100 //! Use of such method or class will cause compiler warning (if supported by
101 //! compiler and unless disabled).
102 //! If macro OCCT_NO_DEPRECATED is defined, Standard_DEPRECATED is defined empty.
103 #ifdef OCCT_NO_DEPRECATED
104 #define Standard_DEPRECATED(theMsg)
106 #if defined(_MSC_VER)
107 #define Standard_DEPRECATED(theMsg) __declspec(deprecated(theMsg))
108 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || defined(__clang__))
109 #define Standard_DEPRECATED(theMsg) __attribute__((deprecated(theMsg)))
110 #elif defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
111 #define Standard_DEPRECATED(theMsg) __attribute__((deprecated))
113 #define Standard_DEPRECATED(theMsg)
117 //! @def Standard_DISABLE_DEPRECATION_WARNINGS
118 //! Disables warnings on use of deprecated features (see Standard_DEPRECATED),
119 //! from the current point till appearance of Standard_ENABLE_DEPRECATION_WARNINGS macro.
120 //! This is useful for sections of code kept for backward compatibility and scheduled for removal.
122 //! @def Standard_ENABLE_DEPRECATION_WARNINGS
123 //! Enables warnings on use of deprecated features previously disabled by
124 //! Standard_DISABLE_DEPRECATION_WARNINGS.
125 #if defined(__ICL) || defined (__INTEL_COMPILER)
126 #define Standard_DISABLE_DEPRECATION_WARNINGS __pragma(warning(push)) __pragma(warning(disable:1478))
127 #define Standard_ENABLE_DEPRECATION_WARNINGS __pragma(warning(pop))
128 #elif defined(_MSC_VER)
129 #define Standard_DISABLE_DEPRECATION_WARNINGS __pragma(warning(push)) __pragma(warning(disable:4996))
130 #define Standard_ENABLE_DEPRECATION_WARNINGS __pragma(warning(pop))
131 #elif (defined(__GNUC__) && __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || defined(__clang__)
132 // available since at least gcc 4.2 (maybe earlier), however only gcc 4.6+ supports this pragma inside the function body
133 // CLang also supports this gcc syntax (in addition to "clang diagnostic ignored")
134 #define Standard_DISABLE_DEPRECATION_WARNINGS _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
135 #define Standard_ENABLE_DEPRECATION_WARNINGS _Pragma("GCC diagnostic warning \"-Wdeprecated-declarations\"")
137 #define Standard_DISABLE_DEPRECATION_WARNINGS
138 #define Standard_ENABLE_DEPRECATION_WARNINGS
141 //! @def OCCT_NO_RVALUE_REFERENCE
142 //! Disables methods and constructors that use rvalue references
143 //! (C++11 move semantics) not supported by obsolete compilers.
144 #if (defined(_MSC_VER) && (_MSC_VER < 1600))
145 #define OCCT_NO_RVALUE_REFERENCE
150 // We must be careful including windows.h: it is really poisonous stuff!
151 // The most annoying are #defines of many identifiers that you could use in
152 // normal code without knowing that Windows has its own knowledge of them...
153 // So lets protect ourselves by switching OFF as much as possible of this in advance.
154 // If someone needs more from windows.h, he is encouraged to #undef these symbols
155 // or include windows.h prior to any OCCT stuff.
156 // Note that we define each symbol to itself, so that it still can be used
157 // e.g. as name of variable, method etc.
158 #ifndef WIN32_LEAN_AND_MEAN
159 #define WIN32_LEAN_AND_MEAN /* exclude extra Windows stuff */
162 #define NOMINMAX NOMINMAX /* avoid #define min() and max() */
165 #define NOMSG NOMSG /* avoid #define SendMessage etc. */
168 #define NODRAWTEXT NODRAWTEXT /* avoid #define DrawText etc. */
171 #define NONLS NONLS /* avoid #define CompareString etc. */
174 #define NOGDI NOGDI /* avoid #define SetPrinter (winspool.h) etc. */
177 #define NOSERVICE NOSERVICE
180 #define NOKERNEL NOKERNEL
183 #define NOUSER NOUSER
194 //! @def Standard_EXPORT
195 //! This macro should be used in declarations of public methods
196 //! to ensure that they are exported from DLL on Windows and thus
197 //! can be called from other (dependent) libraries or applications.
199 //! If macro OCCT_STATIC_BUILD is defined, then Standard_EXPORT
202 # if defined(_WIN32) && !defined(OCCT_STATIC_BUILD) && !defined(HAVE_NO_DLL)
204 //======================================================
205 // Windows-specific definitions
206 //======================================================
208 # ifndef Standard_EXPORT
209 # define Standard_EXPORT __declspec( dllexport )
210 // For global variables :
211 # define Standard_EXPORTEXTERN __declspec( dllexport ) extern
212 # define Standard_EXPORTEXTERNC extern "C" __declspec( dllexport )
213 # endif /* Standard_EXPORT */
215 # ifndef Standard_IMPORT
216 # define Standard_IMPORT __declspec( dllimport ) extern
217 # define Standard_IMPORTC extern "C" __declspec( dllimport )
218 # endif /* Standard_IMPORT */
222 //======================================================
223 // UNIX / static library definitions
224 //======================================================
226 # ifndef Standard_EXPORT
227 # define Standard_EXPORT
228 // For global variables :
229 # define Standard_EXPORTEXTERN extern
230 # define Standard_EXPORTEXTERNC extern "C"
231 # endif /* Standard_EXPORT */
233 # ifndef Standard_IMPORT
234 # define Standard_IMPORT extern
235 # define Standard_IMPORTC extern "C"
236 # endif /* Standard_IMPORT */
238 // Compatibility with old SUN compilers
240 // This preprocessor directive is a kludge to get around
241 // a bug in the Sun Workshop 5.0 compiler, it keeps the
242 // /usr/include/memory.h file from being #included
243 // with an incompatible extern "C" definition of memchr
244 // October 18, 2000 <rboehne@ricardo-us.com>
245 #if __SUNPRO_CC_COMPAT == 5
252 //! This macro is defined on Windows platform in the case if the code
253 //! is being compiled for UWP (Universal Windows Platform).
254 #if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_APP