73747e6fd787285aa99560e83aba635857c38660
[occt.git] / src / Standard / Standard_Macro.hxx
1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
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.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 // Purpose:   This file is intended to be the first file #included to any
16 //            Open CASCADE source. It defines platform-specific pre-processor 
17 //            macros necessary for correct compilation of Open CASCADE code
18
19 #ifndef _Standard_Macro_HeaderFile
20 # define _Standard_Macro_HeaderFile
21
22 #if defined(__cplusplus) && (__cplusplus >= 201100L)
23   // part of C++11 standard
24   #define Standard_OVERRIDE override
25 #elif defined(_MSC_VER) && (_MSC_VER >= 1700)
26   // MSVC extension since VS2012
27   #define Standard_OVERRIDE override
28 #else
29   #define Standard_OVERRIDE
30 #endif
31
32 // Macro Standard_DEPRECATED("message") can be used to declare a method deprecated.
33 // If OCCT_NO_DEPRECATED is defined, Standard_DEPRECATED is defined empty.
34 #ifdef OCCT_NO_DEPRECATED
35   #define Standard_DEPRECATED(theMsg)
36 #else
37 #if defined(_MSC_VER)
38   #define Standard_DEPRECATED(theMsg) __declspec(deprecated(theMsg))
39 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || defined(__clang__))
40   #define Standard_DEPRECATED(theMsg) __attribute__((deprecated(theMsg)))
41 #elif defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
42   #define Standard_DEPRECATED(theMsg) __attribute__((deprecated))
43 #else
44   #define Standard_DEPRECATED(theMsg)
45 #endif
46 #endif
47
48 // Disable warnings about deprecated features.
49 // This is useful for sections of code kept for backward compatibility and scheduled for removal.
50
51 #if defined(__ICL) || defined (__INTEL_COMPILER)
52   #define Standard_DISABLE_DEPRECATION_WARNINGS __pragma(warning(push)) __pragma(warning(disable:1478))
53   #define Standard_ENABLE_DEPRECATION_WARNINGS  __pragma(warning(pop))
54 #elif defined(_MSC_VER)
55   #define Standard_DISABLE_DEPRECATION_WARNINGS __pragma(warning(push)) __pragma(warning(disable:4996))
56   #define Standard_ENABLE_DEPRECATION_WARNINGS  __pragma(warning(pop))
57 #elif (defined(__GNUC__) && __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || defined(__clang__)
58   // available since at least gcc 4.2 (maybe earlier), however only gcc 4.6+ supports this pragma inside the function body
59   // CLang also supports this gcc syntax (in addition to "clang diagnostic ignored")
60   #define Standard_DISABLE_DEPRECATION_WARNINGS _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
61   #define Standard_ENABLE_DEPRECATION_WARNINGS  _Pragma("GCC diagnostic warning \"-Wdeprecated-declarations\"")
62 #else
63   #define Standard_DISABLE_DEPRECATION_WARNINGS
64   #define Standard_ENABLE_DEPRECATION_WARNINGS
65 #endif
66
67 //======================================================
68 // Windows-specific definitions
69 //======================================================
70
71 # if defined(_WIN32) && !defined(HAVE_NO_DLL)
72
73 #  ifndef Standard_EXPORT
74 #   define Standard_EXPORT __declspec( dllexport )
75 // For global variables :
76 #   define Standard_EXPORTEXTERN __declspec( dllexport ) extern
77 #   define Standard_EXPORTEXTERNC extern "C" __declspec( dllexport )
78 #  endif  /* Standard_EXPORT */
79
80 #  ifndef Standard_IMPORT
81 #   define Standard_IMPORT __declspec( dllimport ) extern
82 #   define Standard_IMPORTC extern "C" __declspec( dllimport )
83 #  endif  /* Standard_IMPORT */
84
85 // We must be careful including windows.h: it is really poisonous stuff!
86 // The most annoying are #defines of many identifiers that you could use in 
87 // normal code without knowing that Windows has its own knowledge of them...
88 // So lets protect ourselves by switching OFF as much as possible of this in advance.
89 // If someone needs more from windows.h, he is encouraged to #undef these symbols
90 // or include windows.h prior to any OCCT stuff.
91 // Note that we define each symbol to itself, so that it still can be used
92 // e.g. as name of variable, method etc.
93 #ifndef WIN32_LEAN_AND_MEAN
94 #define WIN32_LEAN_AND_MEAN   /* exclude extra Windows stuff */
95 #endif
96 #ifndef NOMINMAX
97 #define NOMINMAX NOMINMAX     /* avoid #define min() and max() */
98 #endif
99 #ifndef NOMSG
100 #define NOMSG NOMSG           /* avoid #define SendMessage etc. */
101 #endif
102 #ifndef NODRAWTEXT
103 #define NODRAWTEXT NODRAWTEXT /* avoid #define DrawText etc. */
104 #endif
105 #ifndef NONLS
106 #define NONLS NONLS           /* avoid #define CompareString etc. */
107 #endif
108 #ifndef NOGDI
109 #define NOGDI NOGDI           /* avoid #define SetPrinter (winspool.h) etc. */
110 #endif
111 #ifndef NOSERVICE
112 #define NOSERVICE NOSERVICE   
113 #endif
114 #ifndef NOKERNEL
115 #define NOKERNEL NOKERNEL
116 #endif
117 #ifndef NOUSER
118 #define NOUSER NOUSER
119 #endif
120 #ifndef NOMCX
121 #define NOMCX NOMCX
122 #endif
123 #ifndef NOIME
124 #define NOIME NOIME
125 #endif
126
127 # else  /* UNIX */
128
129 //======================================================
130 // UNIX definitions
131 //======================================================
132
133 #  ifndef Standard_EXPORT
134 #   define Standard_EXPORT
135 // For global variables :
136 #   define Standard_EXPORTEXTERN extern
137 #   define Standard_EXPORTEXTERNC extern "C"
138 #  endif  /* Standard_EXPORT */
139
140 #  ifndef Standard_IMPORT
141 #   define Standard_IMPORT extern
142 #   define Standard_IMPORTC extern "C"
143 #  endif  /* Standard_IMPORT */
144
145 // Compatibility with old SUN compilers
146
147 // This preprocessor directive is a kludge to get around
148 // a bug in the Sun Workshop 5.0 compiler, it keeps the
149 // /usr/include/memory.h file from being #included
150 // with an incompatible extern "C" definition of memchr
151 // October 18, 2000  <rboehne@ricardo-us.com>
152 #if __SUNPRO_CC_COMPAT == 5
153 #define _MEMORY_H
154 #endif
155
156 # endif  /* _WIN32 */
157
158 //======================================================
159 // Other
160 //======================================================
161
162 # ifndef __Standard_API
163 #   if !defined(_WIN32) || defined(__Standard_DLL) || defined(__FSD_DLL) || defined(__MMgt_DLL) || defined(__OSD_DLL) || defined(__Plugin_DLL) || defined(__Quantity_DLL) || defined(__Resource_DLL) || defined(__SortTools_DLL) || defined(__StdFail_DLL) || defined(__Storage_DLL) || defined(__TColStd_DLL) || defined(__TCollection_DLL) || defined(__TShort_DLL) || defined(__Units_DLL) || defined(__UnitsAPI_DLL) || defined(__Dico_DLL)
164 #    define __Standard_API Standard_EXPORT
165 #    define __Standard_APIEXTERN Standard_EXPORTEXTERN
166 #   else
167 #    define __Standard_API Standard_IMPORT
168 #    define __Standard_APIEXTERN Standard_IMPORT
169 #   endif  // __Standard_DLL
170 # endif  // __Standard_API
171
172 #endif