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     #include <windows.h>
00042     #undef DELETE
00043 
00044 #elif defined(linux) || defined(__linux)
00045 
00046     // Linux
00047     #define SFML_SYSTEM_LINUX
00048 
00049 #elif defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh)
00050 
00051     // MacOS
00052     #define SFML_SYSTEM_MACOS
00053     #include <Carbon/Carbon.h>
00054 
00055 #else
00056 
00057     // Unsupported system
00058     #error This operating system is not supported by SFML library
00059 
00060 #endif
00061 
00062 
00064 // Identify the platform
00066 #if defined(__i386__) || defined(_M_IX86) || defined(_X86_) || defined(__INTEL__) || defined(__i386)
00067 
00068     // Intel x86
00069     #define SFML_PLATFORM_X86
00070 
00071 #elif defined(__amd64__) || defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64)
00072 
00073     // AMD64
00074     #define SFML_PLATFORM_AMD64
00075 
00076 #elif defined(__IA64__) || defined(_M_IA64)
00077 
00078     // Intel IA64
00079     #define SFML_PLATFORM_IA64
00080 
00081 #elif defined(__powerpc__) || defined(_M_PPC) || defined(_ARCH_PPC)
00082 
00083     // Apple PowerPC
00084     #define SFML_PLATFORM_POWERPC
00085 
00086 #else
00087 
00088     // Unsupported platform
00089     #error This platform is not supported by SFML library
00090 
00091 #endif
00092 
00093 
00095 // Define a portable debug macro
00097 #if !defined(NDEBUG)
00098 
00099     #define SFML_DEBUG
00100 
00101 #endif
00102 
00103 
00105 // Define a portable include path for OpenGL header
00107 #if defined(SFML_SYSTEM_MACOS)
00108 
00109     #define SFML_OPENGL_HEADER <OpenGL/gl.h>
00110 
00111 #else
00112 
00113     #define SFML_OPENGL_HEADER <GL/gl.h>
00114 
00115 #endif
00116 
00117 
00119 // Define portable import / export macros
00121 #if defined(SFML_SYSTEM_WINDOWS)
00122 
00123     #ifdef SFML_DYNAMIC
00124 
00125         // Windows platforms
00126         #ifdef SFML_EXPORTS
00127 
00128             // From DLL side, we must export
00129             #define SFML_API __declspec(dllexport)
00130 
00131         #else
00132 
00133             // From client application side, we must import
00134             #define SFML_API __declspec(dllimport)
00135 
00136         #endif
00137 
00138         // For Visual C++ compilers, we also need to turn off this annoying C4251 warning.
00139         // You can read lots ot different things about it, but the point is the code will
00140         // just work fine, and so the simplest way to get rid of this warning is to disable it
00141         #ifdef _MSC_VER
00142 
00143             #pragma warning(disable : 4251)
00144 
00145         #endif
00146 
00147     #else
00148 
00149         // No specific directive needed for static build
00150         #define SFML_API
00151 
00152     #endif
00153 
00154 #else
00155 
00156     // Other platforms don't need to define anything
00157     #define SFML_API
00158 
00159 #endif
00160 
00161 
00163 // Define endianness depending on current platform
00165 #ifdef SFML_PLATFORM_POWERPC
00166 
00167     // Apple PowerPC processors are big endian
00168     #define SFML_BIG_ENDIAN
00169 
00170 #else
00171 
00172     // The other supported processors (x86, IA64, AMD64) are little endian
00173     #define SFML_LITTLE_ENDIAN
00174 
00175 #endif
00176 
00177 
00179 // Define portable types
00181 #include <climits>
00182 
00183 namespace sf
00184 {
00185     // 8 bits integer types
00186     #if UCHAR_MAX == 0xFF
00187         typedef char          Int8;
00188         typedef unsigned char Uint8;
00189     #else
00190         #error No 8 bits integer type for this platform
00191     #endif
00192 
00193     // 16 bits integer types
00194     #if USHRT_MAX == 0xFFFF
00195         typedef short          Int16;
00196         typedef unsigned short Uint16;
00197     #elif UINT_MAX == 0xFFFF
00198         typedef int          Int16;
00199         typedef unsigned int Uint16;
00200     #elif ULONG_MAX == 0xFFFF
00201         typedef long          Int16;
00202         typedef unsigned long Uint16;
00203     #else
00204         #error No 16 bits integer type for this platform
00205     #endif
00206 
00207     // 32 bits integer types
00208     #if USHRT_MAX == 0xFFFFFFFF
00209         typedef short          Int32;
00210         typedef unsigned short Uint32;
00211     #elif UINT_MAX == 0xFFFFFFFF
00212         typedef int          Int32;
00213         typedef unsigned int Uint32;
00214     #elif ULONG_MAX == 0xFFFFFFFF
00215         typedef long          Int32;
00216         typedef unsigned long Uint32;
00217     #else
00218         #error No 32 bits integer type for this platform
00219     #endif
00220 
00221 } // namespace sf
00222 
00223 
00224 #endif // SFML_CONFIG_HPP