MyGUI  3.2.0
MyGUI_Platform.h
Go to the documentation of this file.
00001 
00008 /*
00009     This file is part of MyGUI.
00010 
00011     MyGUI is free software: you can redistribute it and/or modify
00012     it under the terms of the GNU Lesser General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     MyGUI is distributed in the hope that it will be useful,
00017     but WITHOUT ANY WARRANTY; without even the implied warranty of
00018     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019     GNU Lesser General Public License for more details.
00020 
00021     You should have received a copy of the GNU Lesser General Public License
00022     along with MyGUI.  If not, see <http://www.gnu.org/licenses/>.
00023 */
00024 
00025 #ifndef __MYGUI_PLATFORM_H__
00026 #define __MYGUI_PLATFORM_H__
00027 
00028 // Definition of platforms
00029 #define MYGUI_PLATFORM_WIN32        1
00030 #define MYGUI_PLATFORM_LINUX        2
00031 #define MYGUI_PLATFORM_APPLE        3
00032 
00033 // Definition of compilers
00034 #define MYGUI_COMPILER_MSVC 1
00035 #define MYGUI_COMPILER_GNUC 2
00036 
00037 
00038 // Find platform
00039 #if defined (__WIN32__) || defined (_WIN32)
00040 #   define MYGUI_PLATFORM MYGUI_PLATFORM_WIN32
00041 #elif defined (__APPLE_CC__)
00042 #   define MYGUI_PLATFORM MYGUI_PLATFORM_APPLE
00043 #else
00044 #   define MYGUI_PLATFORM MYGUI_PLATFORM_LINUX
00045 #endif
00046 
00047 // Find compiler
00048 #if defined( _MSC_VER )
00049 #   define MYGUI_COMPILER MYGUI_COMPILER_MSVC
00050 #   define MYGUI_COMP_VER _MSC_VER
00051 
00052 #elif defined( __GNUC__ )
00053 #   define MYGUI_COMPILER MYGUI_COMPILER_GNUC
00054 #   define MYGUI_COMP_VER (((__GNUC__)*100) + \
00055         (__GNUC_MINOR__*10) + \
00056         __GNUC_PATCHLEVEL__)
00057 #else
00058 #   pragma error "Unknown compiler! Stop building!!!"
00059 #endif
00060 
00061 // See if we can use __forceinline or if we need to use __inline instead
00062 #if MYGUI_COMPILER == MYGUI_COMPILER_MSVC
00063 #   if MYGUI_COMP_VER >= 1200
00064 #       define MYGUI_FORCEINLINE __forceinline
00065 #   endif
00066 #elif defined(__MINGW32__)
00067 #   if !defined(MYGUI_FORCEINLINE)
00068 #       define MYGUI_FORCEINLINE __inline
00069 #   endif
00070 #else
00071 #   define MYGUI_FORCEINLINE __inline
00072 #endif
00073 
00074 
00075 // Windows settings
00076 #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
00077 #
00078 #   if defined( MYGUI_STATIC )
00079 #       define MYGUI_EXPORT
00080 #   elif defined( MYGUI_BUILD )
00081 #       define MYGUI_EXPORT __declspec( dllexport )
00082 #   else
00083 #       if defined( __MINGW32__ )
00084 #           define MYGUI_EXPORT
00085 #       else
00086 #           define MYGUI_EXPORT __declspec( dllimport )
00087 #       endif
00088 #   endif
00089 #
00090 #   if defined( MYGUI_STATIC )
00091 #       define MYGUI_EXPORT_DLL
00092 #   elif defined( MYGUI_BUILD_DLL )
00093 #       define MYGUI_EXPORT_DLL __declspec( dllexport )
00094 #   else
00095 #       if defined( __MINGW32__ )
00096 #           define MYGUI_EXPORT_DLL
00097 #       else
00098 #           define MYGUI_EXPORT_DLL __declspec( dllimport )
00099 #       endif
00100 #   endif
00101 #
00102 #// Win32 compilers use _DEBUG for specifying debug builds.
00103 #   ifdef _DEBUG
00104 #       define MYGUI_DEBUG_MODE 1
00105 #   else
00106 #       define MYGUI_DEBUG_MODE 0
00107 #   endif
00108 #endif
00109 
00110 
00111 // Linux/Apple Settings
00112 #if MYGUI_PLATFORM == MYGUI_PLATFORM_LINUX || MYGUI_PLATFORM == MYGUI_PLATFORM_APPLE
00113 #
00114 // Add -fvisibility=hidden to compiler options. With -fvisibility=hidden, you are telling
00115 // GCC that every declaration not explicitly marked with a visibility attribute (MYGUI_EXPORT)
00116 // has a hidden visibility (like in windows).
00117 #   if __GNUC__ >= 4
00118 #       define MYGUI_EXPORT  __attribute__ ((visibility("default")))
00119 #   else
00120 #       define MYGUI_EXPORT
00121 #   endif
00122 #
00123 #   if __GNUC__ >= 4
00124 #       define MYGUI_EXPORT_DLL  __attribute__ ((visibility("default")))
00125 #   else
00126 #       define MYGUI_EXPORT_DLL
00127 #   endif
00128 #
00129 // Unlike the Win32 compilers, Linux compilers seem to use DEBUG for when
00130 // specifying a debug build.
00131 // (??? this is wrong, on Linux debug builds aren't marked in any way unless
00132 // you mark it yourself any way you like it -- zap ???)
00133 #   ifdef DEBUG
00134 #       define MYGUI_DEBUG_MODE 1
00135 #   else
00136 #       define MYGUI_DEBUG_MODE 0
00137 #   endif
00138 
00139 #   if MYGUI_PLATFORM == MYGUI_PLATFORM_APPLE
00140 #       define MYGUI_PLATFORM_LIB "MYGUIPlatform.bundle"
00141 #   else // if MYGUI_PLATFORM_LINUX
00142 #       define MYGUI_PLATFORM_LIB "libMYGUIPlatform.so"
00143 #   endif
00144 
00145 #endif
00146 
00147 
00148 #endif // __MYGUI_PLATFORM_H__