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 // Define a portable debug macro
00063 #if !defined(NDEBUG)
00064 
00065     #define SFML_DEBUG
00066 
00067 #endif
00068 
00069 
00071 // Define portable import / export macros
00073 #if defined(SFML_SYSTEM_WINDOWS)
00074 
00075     #ifdef SFML_DYNAMIC
00076 
00077         // Windows platforms
00078         #ifdef SFML_EXPORTS
00079 
00080             // From DLL side, we must export
00081             #define SFML_API __declspec(dllexport)
00082 
00083         #else
00084 
00085             // From client application side, we must import
00086             #define SFML_API __declspec(dllimport)
00087 
00088         #endif
00089 
00090         // For Visual C++ compilers, we also need to turn off this annoying C4251 warning.
00091         // You can read lots ot different things about it, but the point is the code will
00092         // just work fine, and so the simplest way to get rid of this warning is to disable it
00093         #ifdef _MSC_VER
00094 
00095             #pragma warning(disable : 4251)
00096 
00097         #endif
00098 
00099     #else
00100 
00101         // No specific directive needed for static build
00102         #define SFML_API
00103 
00104     #endif
00105 
00106 #else
00107 
00108     // Other platforms don't need to define anything
00109     #define SFML_API
00110 
00111 #endif
00112 
00113 
00115 // Define portable fixed-size types
00117 #include <climits>
00118 
00119 namespace sf
00120 {
00121     // 8 bits integer types
00122     #if UCHAR_MAX == 0xFF
00123         typedef signed   char Int8;
00124         typedef unsigned char Uint8;
00125     #else
00126         #error No 8 bits integer type for this platform
00127     #endif
00128 
00129     // 16 bits integer types
00130     #if USHRT_MAX == 0xFFFF
00131         typedef signed   short Int16;
00132         typedef unsigned short Uint16;
00133     #elif UINT_MAX == 0xFFFF
00134         typedef signed   int Int16;
00135         typedef unsigned int Uint16;
00136     #elif ULONG_MAX == 0xFFFF
00137         typedef signed   long Int16;
00138         typedef unsigned long Uint16;
00139     #else
00140         #error No 16 bits integer type for this platform
00141     #endif
00142 
00143     // 32 bits integer types
00144     #if USHRT_MAX == 0xFFFFFFFF
00145         typedef signed   short Int32;
00146         typedef unsigned short Uint32;
00147     #elif UINT_MAX == 0xFFFFFFFF
00148         typedef signed   int Int32;
00149         typedef unsigned int Uint32;
00150     #elif ULONG_MAX == 0xFFFFFFFF
00151         typedef signed   long Int32;
00152         typedef unsigned long Uint32;
00153     #else
00154         #error No 32 bits integer type for this platform
00155     #endif
00156 
00157 } // namespace sf
00158 
00159 
00160 #endif // SFML_CONFIG_HPP