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