platforms.hpp
1 /******************************************************************************
2 
3  nomlib - C++11 cross-platform game engine
4 
5 Copyright (c) 2013, Jeffrey Carpenter <jeffrey.carp@gmail.com>
6 All rights reserved.
7 
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
10 
11 1. Redistributions of source code must retain the above copyright notice, this
12  list of conditions and the following disclaimer.
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 ******************************************************************************/
29 #ifndef NOMLIB_PLATFORMS_HEADERS
30 #define NOMLIB_PLATFORMS_HEADERS
31 
37 
38 #if defined ( _WIN32) || defined ( __WIN32__ )
39  #define NOM_PLATFORM_WINDOWS
40 #elif defined ( linux ) || defined ( __linux )
41  #define NOM_PLATFORM_LINUX
42 #elif defined ( __APPLE__ ) || defined ( MACOSX ) || defined ( macintosh ) || defined ( Macintosh )
43  #define NOM_PLATFORM_OSX
44 #endif
45 
48 #if defined ( __i386__ )
49  #define NOM_PLATFORM_ARCH_X86 1
50 #elif defined ( __x86_64__ )
51  #define NOM_PLATFORM_ARCH_X86_64 1
52 #endif
53 
54 // Function names and preferably also its type signature
55 #if defined ( _MSC_VER ) // MSVC++
56  // TODO: Presumably the same as GNU's __PRETTY_FUNCTION__ ?
57  //
58  // SOURCE: http://msdn.microsoft.com/en-us/library/b0084kay(v=vs.80).aspx
59  #define __func__ __FUNCTION__
60 #else // We assume GNU v2+
61 
62  // The type signature is nice because this shows if the function calling type
63  // is a virtual or not and even what arguments the function has
64  #define __func__ __PRETTY_FUNCTION__
65 #endif
66 
67 #ifdef PATH_MAX
68  #undef PATH_MAX
69 #endif
70 
71 // Apparently determining a safe, portable maximum file path is a bit trickier
72 // than meets the eye -- for the time being, I am going to assume the POSIX
73 // standard of 256 bytes is sufficient for my needs. I have my doubts as to this
74 // working out well for us if nomlib ever sees the light of day on the Windows
75 // platform, but alas!
76 //
77 // See http://stackoverflow.com/questions/833291/is-there-an-equivalent-to-winapis-max-path-under-linux-unix
78 #define PATH_MAX 256
79 
80 #endif // include guard