cc5d7260c7d029138a14b2e945dfaddb712177d7
[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 #ifdef HAVE_CONFIG_H
23 # include <config.h>
24 #endif /* HAVE_CONFIG_H */
25
26 // Standard OCC macros: Handle(), STANDARD_TYPE()
27 # define   Handle(ClassName)      Handle_##ClassName
28 # define   STANDARD_TYPE(aType)   aType##_Type_()
29
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 VS2005
35   #define Standard_OVERRIDE override
36 #else
37   #define Standard_OVERRIDE
38 #endif
39
40 //======================================================
41 // Windows-specific definitions
42 //======================================================
43
44 // check if WNT macro is not defined but compiler is MSVC
45 #if defined(_MSC_VER) && !defined(WNT)
46 #error "Wrong compiler options has been detected. Add /DWNT option for proper compilation!!!!!"
47 #endif
48
49 # if defined(_WIN32) && !defined(HAVE_NO_DLL)
50
51 #  ifndef Standard_EXPORT
52 #   define Standard_EXPORT __declspec( dllexport )
53 // For global variables :
54 #   define Standard_EXPORTEXTERN __declspec( dllexport ) extern
55 #   define Standard_EXPORTEXTERNC extern "C" __declspec( dllexport )
56 #  endif  /* Standard_EXPORT */
57
58 #  ifndef Standard_IMPORT
59 #   define Standard_IMPORT __declspec( dllimport ) extern
60 #   define Standard_IMPORTC extern "C" __declspec( dllimport )
61 #  endif  /* Standard_IMPORT */
62
63 // We must be careful including windows.h: it is really poisonous stuff!
64 // The most annoying are #defines of many identifiers that you could use in 
65 // normal code without knowing that Windows has its own knowledge of them...
66 // So lets protect ourselves by switching OFF as much as possible of this in advance.
67 // If someone needs more from windows.h, he is encouraged to #undef these symbols
68 // or include windows.h prior to any OCCT stuff.
69 // Note that we define each symbol to itself, so that it still can be used
70 // e.g. as name of variable, method etc.
71 #ifndef WIN32_LEAN_AND_MEAN
72 #define WIN32_LEAN_AND_MEAN   /* exclude extra Windows stuff */
73 #endif
74 #ifndef NOMINMAX
75 #define NOMINMAX NOMINMAX     /* avoid #define min() and max() */
76 #endif
77 #ifndef NOMSG
78 #define NOMSG NOMSG           /* avoid #define SendMessage etc. */
79 #endif
80 #ifndef NODRAWTEXT
81 #define NODRAWTEXT NODRAWTEXT /* avoid #define DrawText etc. */
82 #endif
83 #ifndef NONLS
84 #define NONLS NONLS           /* avoid #define CompareString etc. */
85 #endif
86 #ifndef NOGDI
87 #define NOGDI NOGDI           /* avoid #define SetPrinter (winspool.h) etc. */
88 #endif
89 #ifndef NOSERVICE
90 #define NOSERVICE NOSERVICE   
91 #endif
92 #ifndef NOKERNEL
93 #define NOKERNEL NOKERNEL
94 #endif
95 #ifndef NOUSER
96 #define NOUSER NOUSER
97 #endif
98 #ifndef NOMCX
99 #define NOMCX NOMCX
100 #endif
101 #ifndef NOIME
102 #define NOIME NOIME
103 #endif
104
105 # else  /* WNT */
106
107 //======================================================
108 // UNIX definitions
109 //======================================================
110
111 #  ifndef Standard_EXPORT
112 #   define Standard_EXPORT
113 // For global variables :
114 #   define Standard_EXPORTEXTERN extern
115 #   define Standard_EXPORTEXTERNC extern "C"
116 #  endif  /* Standard_EXPORT */
117
118 #  ifndef Standard_IMPORT
119 #   define Standard_IMPORT extern
120 #   define Standard_IMPORTC extern "C"
121 #  endif  /* Standard_IMPORT */
122
123 // Compatibility with old SUN compilers
124
125 // This preprocessor directive is a kludge to get around
126 // a bug in the Sun Workshop 5.0 compiler, it keeps the
127 // /usr/include/memory.h file from being #included
128 // with an incompatible extern "C" definition of memchr
129 // October 18, 2000  <rboehne@ricardo-us.com>
130 #if __SUNPRO_CC_COMPAT == 5
131 #define _MEMORY_H
132 #endif
133
134 # endif  /* WNT */
135
136 //======================================================
137 // Other
138 //======================================================
139
140 # ifndef __Standard_API
141 //#  ifdef WNT
142 #   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)
143 #    define __Standard_API Standard_EXPORT
144 #    define __Standard_APIEXTERN Standard_EXPORTEXTERN
145 #   else
146 #    define __Standard_API Standard_IMPORT
147 #    define __Standard_APIEXTERN Standard_IMPORT
148 #   endif  // __Standard_DLL
149 //#  else
150 //#   define __Standard_API
151 //#  endif  // WNT
152 # endif  // __Standard_API
153
154 #endif