base/core_prerequisites.h Source File - 0.9.0 |RTTR
core_prerequisites.h
Go to the documentation of this file.
1 /************************************************************************************
2 * *
3 * Copyright (c) 2014 Axel Menzel <info@axelmenzel.de> *
4 * *
5 * This file is part of RTTR (Run Time Type Reflection) *
6 * License: MIT License *
7 * *
8 * Permission is hereby granted, free of charge, to any person obtaining *
9 * a copy of this software and associated documentation files (the "Software"), *
10 * to deal in the Software without restriction, including without limitation *
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense, *
12 * and/or sell copies of the Software, and to permit persons to whom the *
13 * Software is furnished to do so, subject to the following conditions: *
14 * *
15 * The above copyright notice and this permission notice shall be included in *
16 * all copies or substantial portions of the Software. *
17 * *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *
24 * SOFTWARE. *
25 * *
26 *************************************************************************************/
27 
28 #ifndef __RTTR_CORE_PREREQUISITES_H__
29 #define __RTTR_CORE_PREREQUISITES_H__
30 
31 #include "rttr/base/version.h"
32 
33 namespace rttr
34 {
35 
36 #define RTTR_PLATFORM_WINDOWS 1
37 #define RTTR_PLATFORM_LINUX 2
38 
39 #define RTTR_COMPILER_MSVC 1
40 #define RTTR_COMPILER_GNUC 2
41 
42 #define RTTR_ENDIAN_LITTLE 1
43 #define RTTR_ENDIAN_BIG 2
44 
45 #define RTTR_ARCH_32 1
46 #define RTTR_ARCH_64 2
47 
49 // Platform
51 #if defined( __WIN32__ ) || defined( _WIN32 )
52 # define RTTR_PLATFORM RTTR_PLATFORM_WINDOWS
53 #else
54 # define RTTR_PLATFORM RTTR_PLATFORM_LINUX
55 #endif
56 
58 // Compiler
60 #if defined( __GNUC__ )
61 # define RTTR_COMPILER RTTR_COMPILER_GNUC
62 # define RTTR_COMP_VER (((__GNUC__)*1000) + \
63  (__GNUC_MINOR__*100) + \
64  __GNUC_PATCHLEVEL__)
65 #elif defined( _MSC_VER )
66 # define RTTR_COMPILER RTTR_COMPILER_MSVC
67 # define RTTR_COMP_VER _MSC_VER
68 #else
69 # error "No known compiler. Abort! Abort!"
70 #endif
71 
72 
74 // Architecture
76 #if defined(__x86_64__) || defined(_M_X64) || defined(__powerpc64__) || defined(__alpha__) ||\
77  defined(__ia64__) || defined(__s390__) || defined(__s390x__)
78 # define RTTR_ARCH_TYPE RTTR_ARCH_64
79 #else
80 # define RTTR_ARCH_TYPE RTTR_ARCH_32
81 #endif
82 
83 #if RTTR_COMPILER == RTTR_COMPILER_MSVC
84 # define RTTR_INLINE inline
85 # define RTTR_FORCE_INLINE __forceinline
86 #elif RTTR_COMPILER == RTTR_COMPILER_GNUC
87 # define RTTR_INLINE inline
88 # define RTTR_FORCE_INLINE inline __attribute__((always_inline))
89 #else
90 # define RTTR_INLINE inline
91 # define RTTR_FORCE_INLINE inline // no force inline for other platforms possible
92 #endif
93 
94 
96 // Compiler specific cmds for export and import code to DLL
98 #if RTTR_COMPILER == RTTR_COMPILER_MSVC || __MINGW32__ || __CYGWIN__
99 # define RTTR_HELPER_DLL_IMPORT __declspec( dllimport )
100 # define RTTR_HELPER_DLL_EXPORT __declspec( dllexport )
101 # define RTTR_HELPER_DLL_LOCAL
102 #elif RTTR_COMPILER == RTTR_COMPILER_GNUC
103 # if RTTR_COMP_VER >= 4000
104 # define RTTR_HELPER_DLL_IMPORT __attribute__ ((visibility ("default")))
105 # define RTTR_HELPER_DLL_EXPORT __attribute__ ((visibility ("default")))
106 # define RTTR_HELPER_DLL_LOCAL __attribute__ ((visibility ("hidden")))
107 # else
108 # define RTTR_HELPER_DLL_IMPORT
109 # define RTTR_HELPER_DLL_EXPORT
110 # define RTTR_HELPER_DLL_LOCAL
111 # endif
112 #else
113 # error "Do not know how to export classes for this platform"
114 #endif
115 
116 #ifdef RTTR_DLL // compiled as a DLL
117 # ifdef RTTR_DLL_EXPORTS // defined if we are building the DLL
118 # define RTTR_API RTTR_HELPER_DLL_EXPORT
119 # else
120 # define RTTR_API RTTR_HELPER_DLL_IMPORT
121 # endif
122 # define RTTR_LOCAL RTTR_HELPER_DLL_LOCAL
123 #else // it's a static lib.
124 # define RTTR_API
125 # define RTTR_LOCAL
126 #endif
127 
129 // Integer formats of fixed bit width
131 typedef unsigned char uint8;
132 typedef unsigned short uint16;
133 typedef unsigned int uint32;
134 typedef short int16;
135 typedef char int8;
136 typedef int int32;
137 
139 // Disable some MSVC compile warnings
141 #if RTTR_COMPILER == RTTR_COMPILER_MSVC
142 // Save warnings state
143 # pragma warning (push)
144 // Turn off warnings generated by long std templates
145 // This warns about truncation to 255 characters in debug/browse info
146 # pragma warning (disable : 4786)
147 
148 // Turn off warnings generated by long std templates
149 // This warns about truncation to 255 characters in debug/browse info
150 # pragma warning (disable : 4503)
151 
152 // disable: "<type> needs to have dll-interface to be used by clients'
153 // Happens on STL member variables which are not public therefore is ok
154 # pragma warning (disable : 4251)
155 
156 // disable: "non dll-interface class used as base for dll-interface class"
157 // Happens when deriving from Singleton because bug in compiler ignores
158 // template export
159 # pragma warning (disable : 4275)
160 
161 // disable: "C++ Exception Specification ignored"
162 // This is because MSVC 6 did not implement all the C++ exception
163 // specifications in the ANSI C++ draft.
164 # pragma warning( disable : 4290 )
165 
166 // disable: "no suitable definition provided for explicit template
167 // instantiation request" Occurs in VC7 for no justifiable reason on all
168 // #includes of Singleton
169 # pragma warning( disable: 4661)
170 
171 // disable: deprecation warnings when using CRT calls in VC8
172 // These show up on all C runtime lib code in VC8, disable since they clutter
173 // the warnings with things we may not be able to do anything about (e.g.
174 // generated code from nvparse etc). I doubt very much that these calls
175 // will ever be actually removed from VC anyway, it would break too much code.
176 # pragma warning( disable: 4996)
177 
178 // disable: "unreferenced formal parameter"
179 // Many versions of VC have bugs which generate this error in cases where they shouldn't
180 # pragma warning (disable : 4100)
181 #endif
182 
183 } // end namespace rttr
184 
185 #endif // __RTTR_CORE_PREREQUISITES_H__
The namespace for all rttr components.
Definition: core_prerequisites.h:33
unsigned int uint32
Definition: core_prerequisites.h:133
int int32
Definition: core_prerequisites.h:136
char int8
Definition: core_prerequisites.h:135
unsigned short uint16
Definition: core_prerequisites.h:132
short int16
Definition: core_prerequisites.h:134
unsigned char uint8
Definition: core_prerequisites.h:131