MyGUI: MyGUI_Platform.h Source File

MyGUI 3.2.2

MyGUI_Platform.h
Go to the documentation of this file.
1 /*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7 #ifndef MYGUI_PLATFORM_H_
8 #define MYGUI_PLATFORM_H_
9
10 // Definition of platforms
11 #define MYGUI_PLATFORM_WIN32 1
12 #define MYGUI_PLATFORM_LINUX 2
13 #define MYGUI_PLATFORM_APPLE 3
14
15 // Definition of compilers
16 #define MYGUI_COMPILER_MSVC 1
17 #define MYGUI_COMPILER_GNUC 2
18
19
20 // Find platform
21 #if defined (__WIN32__) || defined (_WIN32)
22 # define MYGUI_PLATFORM MYGUI_PLATFORM_WIN32
23 #elif defined (__APPLE_CC__)
24 # define MYGUI_PLATFORM MYGUI_PLATFORM_APPLE
25 #else
26 # define MYGUI_PLATFORM MYGUI_PLATFORM_LINUX
27 #endif
28
29 // Find compiler
30 #if defined( _MSC_VER )
31 # define MYGUI_COMPILER MYGUI_COMPILER_MSVC
32 # define MYGUI_COMP_VER _MSC_VER
33
34 #elif defined( __GNUC__ )
35 # define MYGUI_COMPILER MYGUI_COMPILER_GNUC
36 # define MYGUI_COMP_VER (((__GNUC__)*100) + \
37 (__GNUC_MINOR__*10) + \
38 __GNUC_PATCHLEVEL__)
39 #else
40 # pragma error "Unknown compiler! Stop building!!!"
41 #endif
42
43 // See if we can use __forceinline or if we need to use __inline instead
44 #if MYGUI_COMPILER == MYGUI_COMPILER_MSVC
45 # if MYGUI_COMP_VER >= 1200
46 # define MYGUI_FORCEINLINE __forceinline
47 # endif
48 #elif defined(__MINGW32__)
49 # if !defined(MYGUI_FORCEINLINE)
50 # define MYGUI_FORCEINLINE __inline
51 # endif
52 #else
53 # define MYGUI_FORCEINLINE __inline
54 #endif
55
56
57 // Windows settings
58 #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
59 #
60 # if defined( MYGUI_STATIC )
61 # define MYGUI_EXPORT
62 # elif defined( MYGUI_BUILD )
63 # define MYGUI_EXPORT __declspec( dllexport )
64 # else
65 # if defined( __MINGW32__ )
66 # define MYGUI_EXPORT
67 # else
68 # define MYGUI_EXPORT __declspec( dllimport )
69 # endif
70 # endif
71 #
72 # if defined( MYGUI_STATIC )
73 # define MYGUI_EXPORT_DLL
74 # elif defined( MYGUI_BUILD_DLL )
75 # define MYGUI_EXPORT_DLL __declspec( dllexport )
76 # else
77 # if defined( __MINGW32__ )
78 # define MYGUI_EXPORT_DLL
79 # else
80 # define MYGUI_EXPORT_DLL __declspec( dllimport )
81 # endif
82 # endif
83 #
84 #// Win32 compilers use _DEBUG for specifying debug builds.
85 # ifdef _DEBUG
86 # define MYGUI_DEBUG_MODE 1
87 # else
88 # define MYGUI_DEBUG_MODE 0
89 # endif
90 #endif
91
92
93 // Linux/Apple Settings
94 #if MYGUI_PLATFORM == MYGUI_PLATFORM_LINUX || MYGUI_PLATFORM == MYGUI_PLATFORM_APPLE
95 #
96 // Add -fvisibility=hidden to compiler options. With -fvisibility=hidden, you are telling
97 // GCC that every declaration not explicitly marked with a visibility attribute (MYGUI_EXPORT)
98 // has a hidden visibility (like in windows).
99 # ifdef MYGUI_GCC_VISIBILITY
100 # define MYGUI_EXPORT __attribute__ ((visibility("default")))
101 # define MYGUI_EXPORT_DLL __attribute__ ((visibility("default")))
102 # else
103 # define MYGUI_EXPORT
104 # define MYGUI_EXPORT_DLL
105 # endif
106 #
107 // Unlike the Win32 compilers, Linux compilers seem to use DEBUG for when
108 // specifying a debug build.
109 // (??? this is wrong, on Linux debug builds aren't marked in any way unless
110 // you mark it yourself any way you like it -- zap ???)
111 # ifdef DEBUG
112 # define MYGUI_DEBUG_MODE 1
113 # else
114 # define MYGUI_DEBUG_MODE 0
115 # endif
116
117 # if MYGUI_PLATFORM == MYGUI_PLATFORM_APPLE
118 # define MYGUI_PLATFORM_LIB "MYGUIPlatform.bundle"
119 # else // if MYGUI_PLATFORM_LINUX
120 # define MYGUI_PLATFORM_LIB "libMYGUIPlatform.so"
121 # endif
122
123 #endif
124
125
126 #endif // MYGUI_PLATFORM_H_