- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# FUtils/Platforms.h

    00001 /*
    00002     Copyright (C) 2005-2007 Feeling Software Inc.
    00003     Portions of the code are:
    00004     Copyright (C) 2005-2007 Sony Computer Entertainment America
    00005
    00006     MIT License: http://www.opensource.org/licenses/mit-license.php
    00007 */
    00008 /*
    00009     Based on the FS Import classes:
    00010     Copyright (C) 2005-2006 Feeling Software Inc
    00011     Copyright (C) 2005-2006 Autodesk Media Entertainment
    00012     MIT License: http://www.opensource.org/licenses/mit-license.php
    00013 */
    00014
    00015 #ifndef _FU_PLATFORMS_H_
    00016 #define _FU_PLATFORMS_H_
    00017
    00018 #ifdef FCOLLADA_DLL
    00019 #ifdef WIN32
    00020 // Disable the "private member not available for export" warning,
    00021 // because I don't feel like writing interfaces
    00022 #pragma warning(disable:4251)
    00023 #ifdef FCOLLADA_INTERNAL
    00024 #define FCOLLADA_EXPORT __declspec(dllexport)
    00025 #define FCOLLADA_LOCAL
    00026 #else
    00027 #define FCOLLADA_EXPORT __declspec(dllimport)
    00028 #define FCOLLADA_LOCAL
    00029 #endif // FCOLLADA_INTERNAL
    00030 #elif defined(__APPLE__) || defined(LINUX)
    00031 #define FCOLLADA_EXPORT __attribute__((visibility("default")))
    00032 #define FCOLLADA_LOCAL __attribute__((visibility("hidden")))
    00033 #endif
    00034 #else // FCOLLADA_DLL
    00035 #define FCOLLADA_EXPORT
    00036 #define FCOLLADA_LOCAL
    00037 #endif // FCOLLADA_DLL
    00038
    00039 #ifdef __PPU__
    00040 #define UNICODE
    00041 #endif // __PPU__
    00042
    00043 // Ensure that both UNICODE and _UNICODE are set.
    00044 #ifdef UNICODE
    00045 #ifndef _UNICODE
    00046 #define _UNICODE
    00047 #endif
    00048 #else
    00049 #ifdef _UNICODE
    00050 #define UNICODE
    00051 #endif
    00052 #endif
    00053
    00054 #ifndef _INC_MATH
    00055 #include <math.h>
    00056 #endif // _INC_MATH
    00057
    00058 #ifdef WIN32
    00059
    00060 #pragma warning(disable:4702)
    00061 #ifndef _WIN32_WINNT        // Allow use of features specific to Windows XP or later.
    00062 #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
    00063 #endif
    00064
    00065 #include <windows.h>
    00066 #include <stdio.h>
    00067 #include <wchar.h>
    00068 #else
    00069 #ifdef __APPLE__
    00070 #include <ctype.h>
    00071 #include <wctype.h>
    00072 #include <unistd.h>
    00073 #include <string.h>
    00074 #include <wchar.h>
    00075 #else // __APPLE__
    00076 #if defined(LINUX) || defined(__PPU__)
    00077 #include <ctype.h>
    00078 #include <wctype.h>
    00079 #include <unistd.h>
    00080 #include <string.h>
    00081 #include <wchar.h>
    00082 #include <stdarg.h>
    00083 #include <malloc.h>
    00084 #include <stdlib.h>
    00085 #include <stdio.h>
    00086 #else // OTHER...
    00087 #error "Unsupported platform."
    00088 #endif // LINUX || __PPU__
    00089 #endif // __APPLE__
    00090
    00091 #endif // WIN32
    00092
    00093 // Cross-platform type definitions
    00094 #ifdef WIN32
    00095
    00096 typedef signed char int8;
    00097 typedef short int16;
    00098 typedef long int32;
    00099 typedef __int64 int64;
    00100 typedef unsigned char uint8;
    00101 typedef unsigned short uint16;
    00102 typedef unsigned long uint32;
    00103 typedef unsigned __int64 uint64;
    00104
    00105 #else // For LINUX and __APPLE__
    00106
    00107 typedef signed char int8;
    00108 typedef short int16;
    00109 typedef long int32;
    00110 typedef long long int64;
    00111 typedef unsigned char uint8;
    00112 typedef unsigned short uint16;
    00113 typedef unsigned long uint32;
    00114 typedef unsigned long long uint64;
    00115 typedef unsigned char byte;
    00116
    00117 #ifndef _CLIMITS_
    00118 #include <climits>
    00119 #endif // _CLIMITS_
    00120
    00121 #endif // PLATFORMS
    00122
    00123 // Important functions that some OSes have missing!
    00124 #if defined(__APPLE__) || defined (LINUX)
    00125 inline char* strlower(char* str) { char* it = str; while (*it != 0) { *it = tolower(*it); ++it; } return str; }
    00126 inline wchar_t* wcslwr(wchar_t* str) { wchar_t* it = str; while (*it != 0) { *it = towlower(*it); ++it; } return str; }
    00127 inline int wcsicmp(const wchar_t* s1, const wchar_t* s2) { wchar_t c1 = *s1, c2 = *s2; while (c1 != 0 && c2 != 0) { if (c1 >= 'a' && c1 <= 'z') c1 -= 'a' + 'A'; if (c2 >= 'a' && c2 <= 'z') c2 -= 'a' + 'A'; if (c2 < c1) return -1; else if (c2 > c1) return 1; c1 = *(++s1); c2 = *(++s2); } return 0; }
    00128 #ifndef isinf
    00129 #define isinf __isinff
    00130 #endif
    00131 #define _stricmp strcasecmp
    00132 #define _getcwd getcwd
    00133 #define _chdir chdir
    00134
    00135 #elif defined(__PPU__)
    00136 #define glClearDepth glClearDepthf
    00137
    00138 #endif // __APPLE__ and LINUX
    00139
    00140 // Cross-platform needed functions
    00141 #ifdef WIN32
    00142
    00143 #define vsnprintf _vsnprintf
    00144 #define snprintf _snprintf
    00145 #define vsnwprintf _vsnwprintf
    00146 #if _MSC_VER >= 1400 //vc8.0 use new secure
    00147     #define snwprintf _snwprintf_s
    00148 #else
    00149     #define snwprintf _snwprintf
    00150 #endif // _MSC_VER
    00151
    00152 #define strlower _strlwr
    00153
    00154 #else // WIN32
    00155
    00156 #define vsnwprintf vswprintf
    00157 #define snwprintf swprintf
    00158
    00159 #endif // WIN32
    00160
    00161 // For Doxygen purposes, we stopped using the "using namespace std;" statement and use shortcuts instead.
    00162
    00163 // fstring and character definition
    00164 #ifdef UNICODE
    00165
    00166     #define fchar wchar_t
    00167     #define FC(a) L ## a
    00168
    00169     #define fstrlen wcslen
    00170     #define fstrcmp wcscmp
    00171     #define fstrncpy wcsncpy
    00172     #define fstrrchr wcsrchr
    00173     #define fstrchr wcschr
    00174     #define fsnprintf snwprintf
    00175     #define fvsnprintf vsnwprintf
    00176     #define fstrup _wcsupr
    00177
    00178     #ifdef __PPU__
    00179         #define fstricmp wcscmp     // [claforte] TODO: Implement __PPU__ version of wcsicmp
    00180     #elif defined(WIN32)
    00181         #define fstricmp _wcsicmp
    00182     #else
    00183         #define fstricmp wcsicmp
    00184     #endif // !__PPU__
    00185
    00186     #ifdef WIN32
    00187         #define fstrlower _wcslwr
    00188     #else
    00189         #define fstrlower wcslwr
    00190     #endif // WIN32
    00191
    00192     #ifdef WIN32
    00193         #define fchdir _tchdir
    00194     #else // WIN32
    00195         #define fchdir(a) chdir(FUStringConversion::ToString(a).c_str())
    00196     #endif // !WIN32
    00197
    00198 #else // UNICODE
    00199
    00200     typedef char fchar;
    00201     #define FC(a) a
    00202
    00203     #define fstrlen strlen
    00204     #define fstrcmp strcmp
    00205     #define fstricmp _stricmp
    00206     #define fstrncpy strncpy
    00207     #define fstrrchr strrchr
    00208     #define fstrchr strchr
    00209     #define fstrlower strlower
    00210     #define fsnprintf snprintf
    00211     #define fvsnprintf vsnprintf
    00212     #define fstrup _strupr
    00213
    00214     #define fchdir chdir
    00215
    00216 #endif // UNICODE
    00217
    00218 #ifndef WIN32
    00219 #define MAX_PATH 1024
    00220 #endif // !WIN32
    00221
    00222 #ifdef WIN32
    00223 //#pragma warning(disable:4324) // Don't bother me about forcing the padding of aligned structure.
    00227 //#define ALIGN_STRUCT(byteCount) __declspec(align(byteCount))
    00228 #define ALIGN_STRUCT(byteCount)
    00229 #else // !WIN32
    00230 #define ALIGN_STRUCT(byteCount)
    00231 #endif // WIN32
    00232
    00233 #if defined(WIN32) && _MSC_VER >= 1400
    00234 #define DEPRECATED(versionNumber, alternative) __declspec(deprecated("[" #versionNumber "] This function is now deprecated. Please use '" #alternative "' instead."))
    00235 #else
    00236
    00240 #define DEPRECATED(versionNumber, alternative)
    00241 #endif // WIN32 && MSVS2005
    00242
    00243 #endif // _FU_PLATFORMS_H_