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