Config.hpp

00001 
00002 //
00003 // SFML - Simple and Fast Multimedia Library
00004 // Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
00005 //
00006 // This software is provided 'as-is', without any express or implied warranty.
00007 // In no event will the authors be held liable for any damages arising from the use of this software.
00008 //
00009 // Permission is granted to anyone to use this software for any purpose,
00010 // including commercial applications, and to alter it and redistribute it freely,
00011 // subject to the following restrictions:
00012 //
00013 // 1. The origin of this software must not be misrepresented;
00014 //    you must not claim that you wrote the original software.
00015 //    If you use this software in a product, an acknowledgment
00016 //    in the product documentation would be appreciated but is not required.
00017 //
00018 // 2. Altered source versions must be plainly marked as such,
00019 //    and must not be misrepresented as being the original software.
00020 //
00021 // 3. This notice may not be removed or altered from any source distribution.
00022 //
00024 
00025 #ifndef SFML_CONFIG_HPP
00026 #define SFML_CONFIG_HPP
00027 
00029 // Identify the operating system
00031 #if defined(_WIN32) || defined(__WIN32__)
00032 
00033     // Windows
00034     #define SFML_SYSTEM_WINDOWS
00035     #ifndef WIN32_LEAN_AND_MEAN
00036         #define WIN32_LEAN_AND_MEAN
00037     #endif
00038     #ifndef NOMINMAX
00039         #define NOMINMAX
00040     #endif
00041 
00042 #elif defined(linux) || defined(__linux)
00043 
00044     // Linux
00045     #define SFML_SYSTEM_LINUX
00046 
00047 #elif defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh)
00048 
00049     // MacOS
00050     #define SFML_SYSTEM_MACOS
00051 
00052 #else
00053 
00054     // Unsupported system
00055     #error This operating system is not supported by SFML library
00056 
00057 #endif
00058 
00059 
00061 // Identify the platform
00063 #if defined(__i386__) || defined(_M_IX86) || defined(_X86_) || defined(__INTEL__) || defined(__i386)
00064 
00065     // Intel x86
00066     #define SFML_PLATFORM_X86
00067 
00068 #elif defined(__amd64__) || defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64)
00069 
00070     // AMD64
00071     #define SFML_PLATFORM_AMD64
00072 
00073 #elif defined(__IA64__) || defined(_M_IA64)
00074 
00075     // Intel IA64
00076     #define SFML_PLATFORM_IA64
00077 
00078 #elif defined(__powerpc__) || defined(_M_PPC) || defined(_ARCH_PPC)
00079 
00080     // Apple PowerPC
00081     #define SFML_PLATFORM_POWERPC
00082 
00083 #else
00084 
00085     // Unsupported platform
00086     #error This platform is not supported by SFML library
00087 
00088 #endif
00089 
00090 
00092 // Define a portable debug macro
00094 #if !defined(NDEBUG)
00095 
00096     #define SFML_DEBUG
00097 
00098 #endif
00099 
00100 
00102 // Define portable import / export macros
00104 #if defined(SFML_SYSTEM_WINDOWS)
00105 
00106     #ifdef SFML_DYNAMIC
00107 
00108         // Windows platforms
00109         #ifdef SFML_EXPORTS
00110 
00111             // From DLL side, we must export
00112             #define SFML_API __declspec(dllexport)
00113 
00114         #else
00115 
00116             // From client application side, we must import
00117             #define SFML_API __declspec(dllimport)
00118 
00119         #endif
00120 
00121         // For Visual C++ compilers, we also need to turn off this annoying C4251 warning.
00122         // You can read lots ot different things about it, but the point is the code will
00123         // just work fine, and so the simplest way to get rid of this warning is to disable it
00124         #ifdef _MSC_VER
00125 
00126             #pragma warning(disable : 4251)
00127 
00128         #endif
00129 
00130     #else
00131 
00132         // No specific directive needed for static build
00133         #define SFML_API
00134 
00135     #endif
00136 
00137 #else
00138 
00139     // Other platforms don't need to define anything
00140     #define SFML_API
00141 
00142 #endif
00143 
00144 
00146 // Define endianness depending on current platform
00148 #ifdef SFML_PLATFORM_POWERPC
00149 
00150     // Apple PowerPC processors are big endian
00151     #define SFML_BIG_ENDIAN
00152 
00153 #else
00154 
00155     // The other supported processors (x86, IA64, AMD64) are little endian
00156     #define SFML_LITTLE_ENDIAN
00157 
00158 #endif
00159 
00160 
00162 // Define portable types
00164 #include <climits>
00165 
00166 namespace sf
00167 {
00168     // 8 bits integer types
00169     #if UCHAR_MAX == 0xFF
00170         typedef char          Int8;
00171         typedef unsigned char Uint8;
00172     #else
00173         #error No 8 bits integer type for this platform
00174     #endif
00175 
00176     // 16 bits integer types
00177     #if USHRT_MAX == 0xFFFF
00178         typedef short          Int16;
00179         typedef unsigned short Uint16;
00180     #elif UINT_MAX == 0xFFFF
00181         typedef int          Int16;
00182         typedef unsigned int Uint16;
00183     #elif ULONG_MAX == 0xFFFF
00184         typedef long          Int16;
00185         typedef unsigned long Uint16;
00186     #else
00187         #error No 16 bits integer type for this platform
00188     #endif
00189 
00190     // 32 bits integer types
00191     #if USHRT_MAX == 0xFFFFFFFF
00192         typedef short          Int32;
00193         typedef unsigned short Uint32;
00194     #elif UINT_MAX == 0xFFFFFFFF
00195         typedef int          Int32;
00196         typedef unsigned int Uint32;
00197     #elif ULONG_MAX == 0xFFFFFFFF
00198         typedef long          Int32;
00199         typedef unsigned long Uint32;
00200     #else
00201         #error No 32 bits integer type for this platform
00202     #endif
00203 
00204 } // namespace sf
00205 
00206 
00207 #endif // SFML_CONFIG_HPP