1 #pragma once 2 3 //******************************************************************************************** 4 //* 5 //* This file is part of Egoboo. 6 //* 7 //* Egoboo is free software: you can redistribute it and/or modify it 8 //* under the terms of the GNU General Public License as published by 9 //* the Free Software Foundation, either version 3 of the License, or 10 //* (at your option) any later version. 11 //* 12 //* Egoboo is distributed in the hope that it will be useful, but 13 //* WITHOUT ANY WARRANTY; without even the implied warranty of 14 //* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 //* General Public License for more details. 16 //* 17 //* You should have received a copy of the GNU General Public License 18 //* along with Egoboo. If not, see <http://www.gnu.org/licenses/>. 19 //* 20 //******************************************************************************************** 21 22 /// @file egoboo_platform.h 23 /// @brief System-dependent global parameters. 24 /// @todo some of this stuff is compiler dependent, rather than system dependent. 25 26 #include <SDL.h> ///< use the basic SDL platform definitions 27 28 //-------------------------------------------------------------------------------------------- 29 //-------------------------------------------------------------------------------------------- 30 // osx definitions 31 32 #if defined(__APPLE__) || defined(macintosh) 33 34 // trap non-osx mac builds 35 # if !defined(__MACH__) 36 # error Only OS X builds are supported 37 # endif 38 39 /// make this function work cross-platform 40 # define stricmp strcasecmp 41 42 #endif 43 44 //-------------------------------------------------------------------------------------------- 45 //-------------------------------------------------------------------------------------------- 46 // windows definitions 47 48 #if defined(WIN32) || defined(_WIN32) || defined (__WIN32) || defined(__WIN32__) 49 50 // map all of these possibilities to WIN32 51 # if !defined(WIN32) 52 # define WIN32 53 # endif 54 55 /// Speeds up compile times a bit. We don't need everything in windows.h 56 # undef WIN32_LEAN_AND_MEAN 57 58 /// special win32 macro that lets windows know that you are going to be 59 /// starting from a console. This is useful because you can get real-time 60 /// output to the screen just by using printf()! 61 # if defined(_CONSOLE) 62 # define CONSOLE_MODE 63 # else 64 # undef CONSOLE_MODE 65 # endif 66 67 #endif 68 69 //-------------------------------------------------------------------------------------------- 70 //-------------------------------------------------------------------------------------------- 71 //*nix definitions 72 #if defined(__unix__) || defined(__unix) || defined(_unix) || defined(unix) 73 74 /// map all of these to __unix__ 75 # if !defined(__unix__) 76 # define __unix__ 77 # endif 78 79 # include <unistd.h> 80 81 /// make this function work cross-platform 82 # define stricmp strcasecmp 83 84 #endif 85 86 //-------------------------------------------------------------------------------------------- 87 //-------------------------------------------------------------------------------------------- 88 //amiga definitions 89 #if defined(__amigaos4__) 90 91 /// amigaos uses __unix__ 92 # if !defined(__unix__) 93 # define __unix__ 94 # endif 95 96 # include <unistd.h> 97 98 /// make this function work cross-platform 99 # define stricmp strcasecmp 100 101 #endif 102 //-------------------------------------------------------------------------------------------- 103 //-------------------------------------------------------------------------------------------- 104 105 // os-dependent pathname conventions 106 107 #define C_SLASH_CHR '/' 108 #define C_SLASH_STR "/" 109 110 #define C_BACKSLASH_CHR '\\' 111 #define C_BACKSLASH_STR "\\" 112 113 #define WIN32_SLASH_CHR C_BACKSLASH_CHR 114 #define WIN32_SLASH_STR C_BACKSLASH_STR 115 116 // everyone uses the same convention for the internet... 117 #define NET_SLASH_CHR C_SLASH_CHR 118 #define NET_SLASH_STR C_SLASH_STR 119 120 #if defined(WIN32) || defined(_WIN32) 121 122 # define SLASH_STR WIN32_SLASH_STR 123 # define SLASH_CHR WIN32_SLASH_CHR 124 125 #else 126 127 # define SLASH_STR NET_SLASH_STR 128 # define SLASH_CHR NET_SLASH_CHR 129 130 #endif 131 132 //-------------------------------------------------------------------------------------------- 133 //-------------------------------------------------------------------------------------------- 134 // Compiler-specific definitions 135 136 //------------ 137 // deal with gcc's the warnings about const on return types in C 138 139 #define EGO_CONST 140 141 //------------ 142 // fix how MSVC handles throw specifications on member functions 143 #if defined(_MSC_VER) 144 # define DECL_THROW(XX) throw(...) 145 #else 146 # define DECL_THROW(XX) throw(XX) 147 #endif 148 149 //------------ 150 // localize the inline keyword to the compiler 151 #if defined(_MSC_VER) 152 /// In MS visual C, the "inline" keyword seems to be depricated. Must to be promoted to "_inline" or "__inline" 153 # define INLINE __inline 154 #else 155 # define INLINE inline 156 #endif 157 158 //------------ 159 // Turn off warnings that we don't care about. 160 #if defined(_MSC_VER) 161 # pragma warning(disable : 4090) ///< '=' : different 'const' qualifiers (totally unimportant in C) 162 # pragma warning(disable : 4200) ///< zero-sized array in struct/union (used in the md2 loader) 163 # pragma warning(disable : 4201) ///< nameless struct/union (nameless unions and nameless structs used in defining the vector structs) 164 # pragma warning(disable : 4204) ///< non-constant aggregate initializer (used to simplify some vector initializations) 165 # pragma warning(disable : 4244) ///< conversion from 'double' to 'float' 166 # pragma warning(disable : 4305) ///< truncation from 'double' to 'float' 167 168 # if !defined(_DEBUG) 169 # pragma warning(disable : 4554) ///< possibly operator precendence error 170 # endif 171 172 #endif 173 174 //------------ 175 // fix the naming of some linux-flovored functions in MSVC 176 #if defined(_MSC_VER) 177 # define snprintf _snprintf 178 # define stricmp _stricmp 179 # define isnan _isnan 180 # define strlwr _strlwr 181 182 /// This isn't needed in MSVC 2008 and causes errors 183 # if _MSC_VER < 1500 184 # define vsnprintf _vsnprintf 185 # endif 186 187 #endif 188 189 //------------ 190 // it seems that the gcc community has a bug up its ass about the forward declaration of enums 191 // to get around this (so we can use the strong type checking of c++ to look for errors in the code) 192 // we will define 193 #if !defined(_MSC_VER) 194 # define FWD_ENUM(XX) typedef int i_##XX 195 #else 196 # define FWD_ENUM(XX) enum e_##XX; typedef enum e_##XX i_##XX; 197 #endif 198 199 //------------ 200 #if !defined(SET_PACKED) 201 // set the packing of a data structure at declaration time 202 # if !defined(USE_PACKING) 203 // do not actually do anything about the packing 204 # define SET_PACKED() 205 # else 206 // use compiler-specific macro definitions 207 # if defined(__GNUC__) 208 # define SET_PACKED() __attribute__ ((__packed__)) 209 # elif defined(_MSC_VER) 210 # define SET_PACKED() 211 # endif 212 # endif 213 #endif 214 215 #define EGOBOO_PLATFORM 216