Back to index

nux  3.0.0
System.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2010 Inalogic® Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License, as
00006  * published by the  Free Software Foundation; either version 2.1 or 3.0
00007  * of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00019  *
00020  */
00021 
00022 
00023 #ifndef SYSTEM_H
00024 #define SYSTEM_H
00025 
00026 #ifdef _DEBUG
00027   #define NUX_DEBUG
00028 #endif
00029 
00030 #ifdef _WIN32
00031     #define NUX_OS_WINDOWS
00032 #elif __linux__
00033     #define NUX_OS_LINUX
00034 #elif __APPLE__
00035     #define NUX_OS_MACOSX
00036 #endif
00037 
00038 #if __GNUC__
00039   #define NUX_GNUC_COMPILER
00040   #if __GNUG__
00041     #define NUX_GNUCPP_COMPILER
00042   #else
00043     #error Support only g++.
00044   #endif
00045 
00046   // Compiler string.
00047   #define NUX_COMPILER_STRING "GNU CPP Compiler"
00048 
00049   // Build string
00050   #ifdef NUX_DEBUG
00051     #define NUX_BUILD_STRING "Debug build compiled with " NUX_COMPILER_STRING
00052   #else
00053     #define NUX_BUILD_STRING "Compiled with " NUX_COMPILER_STRING
00054   #endif
00055 #endif
00056 
00057 #if __APPLE_CC__
00058   #define NUX_APPLE_COMPILER
00059 #endif
00060 
00061 #if defined(_MSC_VER)
00062   #define NUX_MICROSOFT_COMPILER
00063 #endif
00064 
00065 #if defined(_M_X64) || defined(__amd64__) || defined(__ia64__)
00066   #define NUX_ARCH_x64
00067 #elif defined(_M_IX86) || defined(__i386__)
00068   #define NUX_ARCH_i386
00069 #elif defined(__arm__)
00070        #define NUX_ARCH_arm
00071 #endif
00072 
00073 
00074 
00075 // Compiler Macros:
00076 // NUX_GNUCPP_COMPILER
00077 // NUX_MICROSOFT_COMPILER
00078 
00079 // OS Macros:
00080 // NUX_OS_WINDOWS
00081 // NUX_OS_LINUX
00082 // NUX_OS_CELL
00083 // NUX_OS_MACOSX
00084 
00085 #ifdef _WIN32
00086 
00087 //    Add lib  DbgHelp.lib for the following function
00088 //    StackWalk64
00089 //    SymFunctionTableAccess64
00090 //    SymGetModuleBase64
00091 //    SymGetModuleInfo64
00092 //    SymGetLineFromAddr64
00093 //    SymGetSymFromAddr64
00094 //    SymInitialize
00095 //    SymSetOptions
00096 //    SymGetOptions
00097 //    SymLoadModule64
00098 #pragma comment(lib, "DbgHelp")
00099 
00100 // _MSC_VER: Defines the major and minor versions of the compiler. For example, 1300 for Microsoft Visual C++ .NET. 1300 represents version 13
00101 // and no point release. This represents the fact that there have been a total of 13 releases of the compiler.
00102 // If you type cl /? at the command line, you will see the full version for the compiler you are using.
00103 
00104 #ifndef _MSC_VER
00105 #error Support only Visual Studio Compiler.
00106 #endif
00107 
00108 #define VISUAL_STUDIO_2010_COMPILER     1600
00109 #define VISUAL_STUDIO_2008_COMPILER     1500
00110 #define VISUAL_STUDIO_2005_COMPILER     1400
00111 #define VISUAL_STUDIO_2003_COMPILER     1310
00112 
00113 #if _MSC_VER >= 1600
00114   #define NUX_VISUAL_STUDIO_2010
00115 #elif _MSC_VER >= 1500
00116   #define NUX_VISUAL_STUDIO_2008
00117 #elif _MSC_VER >= 1400
00118   #define NUX_VISUAL_STUDIO_2005
00119 #elif _MSC_VER >= 1310
00120   #define NUX_VISUAL_STUDIO_2003
00121 #endif
00122 
00123 // Compiler string.
00124 #if (_MSC_VER >= VISUAL_STUDIO_2008_COMPILER)
00125   #define NUX_COMPILER_STRING "Visual Studio 2008"
00126 #elif (_MSC_VER >= VISUAL_STUDIO_2005_COMPILER)
00127   #define NUX_COMPILER_STRING "Visual Studio 2005"
00128 #elif (_MSC_VER >= VISUAL_STUDIO_2003_COMPILER)
00129   #define NUX_COMPILER_STRING "Visual Studio 2003"
00130 #endif
00131 
00132 // Build String
00133 #ifdef NUX_DEBUG
00134 #define NUX_BUILD_STRING "Debug build compiled with " NUX_COMPILER_STRING
00135 #else
00136 #define NUX_BUILD_STRING "Compiled with " NUX_COMPILER_STRING
00137 #endif
00138 
00139 
00140 // Define the proper values for _WIN32_WINNT and WINVER in the compiler response file "compiler_options.h"
00141 //    Windows Vista      _WIN32_WINNT>=0x0600
00142 //                          WINVER>=0x0600
00143 //    Windows Server 2003   _WIN32_WINNT>=0x0502
00144 //                          WINVER>=0x0502
00145 //    Windows XP             _WIN32_WINNT>=0x0501
00146 //                          WINVER>=0x0501
00147 //    Windows 2000           _WIN32_WINNT>=0x0500
00148 //                          WINVER>=0x0500
00149 //    Windows NT 4.0            _WIN32_WINNT>=0x0400
00150 //                          WINVER>=0x0400
00151 //    Windows Me             _WIN32_WINDOWS=0x0500
00152 //                          WINVER>=0x0500
00153 //    Windows 98             _WIN32_WINDOWS>=0x0410
00154 //                          WINVER>=0x0410
00155 //    Windows 95             _WIN32_WINDOWS>=0x0400
00156 //                          WINVER>=0x0400
00157 
00158 
00159 //    Minimum system required      Macros to define
00160 //    Windows Vista  NTDDI_VERSION >=NTDDI_LONGHORN
00161 //    Windows Server 2003 SP1      NTDDI_VERSION >=NTDDI_WS03SP1
00162 //    Windows Server 2003   NTDDI_VERSION >=NTDDI_WS03
00163 //    Windows XP SP2        NTDDI_VERSION >=NTDDI_WINXPSP2
00164 //    Windows XP SP1        NTDDI_VERSION >=NTDDI_WINXPSP1
00165 //    Windows XP     NTDDI_VERSION >=NTDDI_WINXP
00166 //    Windows 2000 SP4      NTDDI_VERSION >=NTDDI_WIN2KSP4
00167 //    Windows 2000 SP3      NTDDI_VERSION >=NTDDI_WIN2KSP3
00168 //    Windows 2000 SP2      NTDDI_VERSION >=NTDDI_WIN2KSP2
00169 //    Windows 2000 SP1      NTDDI_VERSION >=NTDDI_WIN2KSP1
00170 //    Windows 2000   NTDDI_VERSION >=NTDDI_WIN2K
00171 
00172 #define WIN32_LEAN_AND_MEAN 1
00173 #endif  // _WIN32
00174 
00175 
00176 
00177 
00178 // Logging
00179 #if defined(NUX_OS_WINDOWS) && defined(NUX_DEBUG)
00180   #define NUX_ENABLE_ASSERT_MACROS
00181   #define NUX_ENABLE_LOGGING
00182 #elif defined(NUX_OS_LINUX) && defined(NUX_DEBUG)
00183   #define NUX_ENABLE_ASSERT_MACROS
00184   #define NUX_ENABLE_LOGGING
00185 #endif
00186 
00187 // NOP: no operation
00188 // Specifies that a function should be ignored and the argument list
00189 // be parsed but no code be generated for the arguments. It is intended for use in global
00190 // debug functions that take a variable number of arguments.
00191 
00192 #if defined(NUX_MICROSOFT_COMPILER)
00193   #define NUX_COMPILER_SUPPORTS_NOOP
00194   #define NUX_NOOP __noop
00195 #elif defined(NUX_GNUCPP_COMPILER)
00196   #define NUX_COMPILER_SUPPORTS_NOOP
00197   #define NUX_NOOP __asm__("nop")
00198 #endif
00199 
00200 // Pragma pack support
00201 #if defined(NUX_MICROSOFT_COMPILER) || defined(NUX_GNUCPP_COMPILER)
00202   #define NUX_SUPPORTS_PRAGMA_PACK
00203 #endif
00204 
00205 
00206 // Define variadic macro support
00207 #if defined(NUX_MICROSOFT_COMPILER) && (defined(NUX_VISUAL_STUDIO_2005) || defined(NUX_VISUAL_STUDIO_2008) || defined(NUX_VISUAL_STUDIO_2010))
00208     #define NUX_VARIADIC_MACROS_SUPPORT
00209 #elif defined(NUX_GNUCPP_COMPILER)
00210     #define NUX_VARIADIC_MACROS_SUPPORT
00211 #endif
00212 
00213 
00215 #if defined(NUX_OS_WINDOWS)
00216     #ifdef NUX_DLL
00217         #if (!defined(_WIN32)) && (!defined(_WIN64))
00218             #error("ERROR: Use NUX_DLL is permitted only on win32 & win64 platforms")
00219         #endif
00220 
00221         #define NUX_DECLSPEC_DLLIMPORT        __declspec(dllimport)
00222         #define NUX_DECLSPEC_DLLEXPORT        __declspec(dllexport)
00223     #else
00224         #define NUX_DECLSPEC_DLLIMPORT
00225         #define NUX_DECLSPEC_DLLEXPORT
00226     #endif
00227 
00228     #ifdef NUX_EXPORT_DLL
00229         #define NUX_DECLSPEC_DLL               NUX_DECLSPEC_DLLEXPORT
00230     #else
00231         #define NUX_DECLSPEC_DLL               NUX_DECLSPEC_DLLIMPORT
00232     #endif
00233 #elif defined(NUX_OS_LINUX)
00234     #if __GNUC__ >= 4
00235         #define NUX_DECLSPEC_DLLIMPORT __attribute__ ((visibility("default")))
00236         #define NUX_DECLSPEC_DLLEXPORT __attribute__ ((visibility("default")))
00237     #else
00238         #define NUX_DECLSPEC_DLLIMPORT
00239         #define NUX_DECLSPEC_DLLEXPORT
00240     #endif
00241 
00242     #ifdef NUX_EXPORT_DLL
00243         #define NUX_DECLSPEC_DLL               NUX_DECLSPEC_DLLEXPORT
00244     #else
00245         #define NUX_DECLSPEC_DLL               NUX_DECLSPEC_DLLIMPORT
00246     #endif
00247 #endif
00248 
00249 #define NUX_CHECK_PUREVIRTUALS 1
00250 
00251 // Throwing exceptions:
00252 
00253 // #ifdef NUX_DEBUG
00254 //     // if we are in Debug disable exceptions. What we want is to break were and error happens: ie NUX_BREAK_ASM_INT3
00255 //     #define NUX_EXCEPTIONS_DISABLED 1
00256 // #endif
00257 
00258 #define NUX_EXCEPTIONS_DISABLED 1
00259 
00260 #define STL std
00261 
00262 #endif // SYSTEM_H
00263