MyGUI  3.0.1
MyGUI_Platform.h
Go to the documentation of this file.
1 
8 /*
9  This file is part of MyGUI.
10 
11  MyGUI is free software: you can redistribute it and/or modify
12  it under the terms of the GNU Lesser General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  MyGUI is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  GNU Lesser General Public License for more details.
20 
21  You should have received a copy of the GNU Lesser General Public License
22  along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
23 */
24 
25 #ifndef __MYGUI_PLATFORM_H__
26 #define __MYGUI_PLATFORM_H__
27 
28 // Definnition of platforms
29 #define MYGUI_PLATFORM_WIN32 1
30 #define MYGUI_PLATFORM_LINUX 2
31 #define MYGUI_PLATFORM_APPLE 3
32 
33 // Definition of compilers
34 #define MYGUI_COMPILER_MSVC 1
35 #define MYGUI_COMPILER_GNUC 2
36 
37 
38 // Find platform
39 #if defined (__WIN32__) || defined (_WIN32)
40 # define MYGUI_PLATFORM MYGUI_PLATFORM_WIN32
41 #elif defined (__APPLE_CC__)
42 # define MYGUI_PLATFORM MYGUI_PLATFORM_APPLE
43 #else
44 # define MYGUI_PLATFORM MYGUI_PLATFORM_LINUX
45 #endif
46 
47 // Find compiler
48 #if defined( _MSC_VER )
49 # define MYGUI_COMPILER MYGUI_COMPILER_MSVC
50 # define MYGUI_COMP_VER _MSC_VER
51 
52 #elif defined( __GNUC__ )
53 # define MYGUI_COMPILER MYGUI_COMPILER_GNUC
54 # define MYGUI_COMP_VER (((__GNUC__)*100) + \
55  (__GNUC_MINOR__*10) + \
56  __GNUC_PATCHLEVEL__)
57 #else
58 # pragma error "Unknown compiler! Stop building!!!"
59 #endif
60 
61 // See if we can use __forceinline or if we need to use __inline instead
62 #if MYGUI_COMPILER == MYGUI_COMPILER_MSVC
63 # if MYGUI_COMP_VER >= 1200
64 # define MYGUI_FORCEINLINE __forceinline
65 # endif
66 #elif defined(__MINGW32__)
67 # if !defined(MYGUI_FORCEINLINE)
68 # define MYGUI_FORCEINLINE __inline
69 # endif
70 #else
71 # define MYGUI_FORCEINLINE __inline
72 #endif
73 
74 
75 // Windows settings
76 #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
77 #
78 # if defined( MYGUI_STATIC )
79 # define MYGUI_EXPORT
80 # elif defined( MYGUI_BUILD )
81 # define MYGUI_EXPORT __declspec( dllexport )
82 # else
83 # if defined( __MINGW32__ )
84 # define MYGUI_EXPORT
85 # else
86 # define MYGUI_EXPORT __declspec( dllimport )
87 # endif
88 # endif
89 #
90 # if defined( MYGUI_STATIC )
91 # define MYGUI_EXPORT_DLL
92 # elif defined( MYGUI_BUILD_DLL )
93 # define MYGUI_EXPORT_DLL __declspec( dllexport )
94 # else
95 # if defined( __MINGW32__ )
96 # define MYGUI_EXPORT_DLL
97 # else
98 # define MYGUI_EXPORT_DLL __declspec( dllimport )
99 # endif
100 # endif
101 #
102 #// Win32 compilers use _DEBUG for specifying debug builds.
103 # ifdef _DEBUG
104 # define MYGUI_DEBUG_MODE 1
105 # else
106 # define MYGUI_DEBUG_MODE 0
107 # endif
108 #endif
109 
110 
111 // Linux/Apple Settings
112 #if MYGUI_PLATFORM == MYGUI_PLATFORM_LINUX || MYGUI_PLATFORM == MYGUI_PLATFORM_APPLE
113 #
114 // Add -fvisibility=hidden to compiler options. With -fvisibility=hidden, you are telling
115 // GCC that every declaration not explicitly marked with a visibility attribute (MYGUI_EXPORT)
116 // has a hidden visibility (like in windows).
117 # if __GNUC__ >= 4
118 # define MYGUI_EXPORT __attribute__ ((visibility("default")))
119 # else
120 # define MYGUI_EXPORT
121 # endif
122 #
123 # if __GNUC__ >= 4
124 # define MYGUI_EXPORT_DLL __attribute__ ((visibility("default")))
125 # else
126 # define MYGUI_EXPORT_DLL
127 # endif
128 #
129 // A quick define to overcome different names for the same function
130 # define stricmp strcasecmp
131 #
132 // Unlike the Win32 compilers, Linux compilers seem to use DEBUG for when
133 // specifying a debug build.
134 // (??? this is wrong, on Linux debug builds aren't marked in any way unless
135 // you mark it yourself any way you like it -- zap ???)
136 # ifdef DEBUG
137 # define MYGUI_DEBUG_MODE 1
138 # else
139 # define MYGUI_DEBUG_MODE 0
140 # endif
141 
142 # if MYGUI_PLATFORM == MYGUI_PLATFORM_APPLE
143 # define MYGUI_PLATFORM_LIB "MYGUIPlatform.bundle"
144 # else // if MYGUI_PLATFORM_LINUX
145 # define MYGUI_PLATFORM_LIB "libMYGUIPlatform.so"
146 # endif
147 
148 #endif
149 
150 
151 #endif // __MYGUI_PLATFORM_H__