omw  0.2.0
defs.h
Go to the documentation of this file.
1 /*
2 author Oliver Blaser
3 date 25.01.2022
4 copyright MIT - Copyright (c) 2022 Oliver Blaser
5 */
6 
14 #ifndef IG_OMW_DEFS_H
15 #define IG_OMW_DEFS_H
16 
23 
31 #ifndef OMWi_DOXYGEN_PREDEFINE
32 
33 #if defined(__clang__)
34 #define OMW_CXX_CLANG (1)
35 #elif defined(__GNUC__) || defined(__GNUG__)
36 #define OMW_CXX_GCC (1)
37 #elif defined(_MSC_VER)
38 #define OMW_CXX_MSVC (1)
39 #elif defined(__MINGW32__)
40 #define OMW_CXX_MINGW32 (1)
41 #elif defined(__MINGW64__)
42 #define OMW_CXX_MINGW64 (1)
43 #elif defined(__EMSCRIPTEN__)
44 #define OMW_CXX_EMSCRIPTEN (1)
45 #else
46 #define OMW_CXX_UNKNOWN (1)
47 #endif
48 
49 #else // OMWi_DOXYGEN_PREDEFINE
50 #define OMW_CXX_CLANG (1)
51 #define OMW_CXX_GCC (1)
52 #define OMW_CXX_MSVC (1)
53 #define OMW_CXX_MINGW32 (1)
54 #define OMW_CXX_MINGW64 (1)
55 #define OMW_CXX_EMSCRIPTEN (1)
56 #define OMW_CXX_UNKNOWN (1)
57 #endif // OMWi_DOXYGEN_PREDEFINE
58 
60 
61 
62 
71 
72 #ifndef OMWi_DOXYGEN_PREDEFINE
73 
74 #ifdef _WIN32
75 #define OMW_PLAT_WIN (1)
76 #ifdef _WIN64
77 #define OMW_PLAT_WIN64 (1)
78 #else // _WIN64
79 #define OMW_PLAT_WIN32 (1)
80 #endif // _WIN64
81 #endif // _WIN32
82 
83 #if (defined(__unix__) || defined(__unix))
84 #define OMW_PLAT_UNIX (1)
85 #include <unistd.h>
86 #ifdef _POSIX_VERSION
87 #define OMW_PLAT_POSIX (1)
88 #endif // _POSIX_VERSION
89 #endif // Unix
90 
91 #ifdef __linux__
92 #define OMW_PLAT_LINUX (1)
93 #endif // __linux__
94 
95 #if (defined(__APPLE__) && defined(__MACH__))
96 #define OMW_PLAT_APPLE (1)
97 #endif // Apple
98 
99 
100 
101 #if (defined(OMW_PLAT_UNIX) || defined(OMW_PLAT_APPLE))
102 #include <sys/param.h>
103 #ifdef BSD
104 #define OMW_PLAT_BSD (1)
105 #endif // BSD
106 #endif // Unix or Apple
107 
108 #if !(defined(OMW_PLAT_WIN) || defined(OMW_PLAT_UNIX) || defined(OMW_PLAT_LINUX) || defined(OMW_PLAT_APPLE))
109 #define OMW_PLAT_UNKNOWN (1)
110 #endif
111 
112 
113 
114 #else // OMWi_DOXYGEN_PREDEFINE
115 #define OMW_PLAT_WIN (1)
116 #define OMW_PLAT_WIN32 (1)
117 #define OMW_PLAT_WIN64 (1)
118 #define OMW_PLAT_UNIX (1)
119 #define OMW_PLAT_POSIX (1)
120 #define OMW_PLAT_LINUX (1)
121 #define OMW_PLAT_APPLE (1)
122 #define OMW_PLAT_BSD (1)
123 #define OMW_PLAT_UNKNOWN (1)
124 #endif // OMWi_DOXYGEN_PREDEFINE
125 
127 
128 
129 
137 
138 #ifndef OMWi_DOXYGEN_PREDEFINE
139 
140 #ifdef OMW_CXX_MSVC
141 
142 #if defined(_M_IX86)
143 #define OMW_PARCH_x86_32 (1)
144 #elif (defined(_M_AMD64) || defined(_M_X64))
145 #define OMW_PARCH_x86_64 (1)
146 #elif defined(_M_ARM64)
147 #define OMW_PARCH_ARM64 (1)
148 #elif defined(_M_ARM)
149 #define OMW_PARCH_ARM32 (1)
150 #else
151 #define OMW_PARCH_UNKNOWN (1)
152 #endif
153 
154 #else // OMW_CXX_MSVC
155 
156 #if defined(__i386__)
157 #define OMW_PARCH_x86_32 (1)
158 #elif defined(__x86_64__)
159 #define OMW_PARCH_x86_64 (1)
160 #elif defined(__aarch64__)
161 #define OMW_PARCH_ARM64 (1)
162 #elif defined(__arm__)
163 #define OMW_PARCH_ARM32 (1)
164 #elif defined(__powerpc64__)
165 #define OMW_PARCH_POWERPC (1)
166 #else
167 #define OMW_PARCH_UNKNOWN (1)
168 #endif
169 
170 #endif // OMW_CXX_MSVC
171 
172 
173 
174 #else // OMWi_DOXYGEN_PREDEFINE
175 #define OMW_PARCH_x86_32 (1)
176 #define OMW_PARCH_x86_64 (1)
177 #define OMW_PARCH_ARM32 (1)
178 #define OMW_PARCH_ARM64 (1)
179 #define OMW_PARCH_POWERPC (1)
180 #define OMW_PARCH_UNKNOWN (1)
181 #endif // OMWi_DOXYGEN_PREDEFINE
182 
184 
185 
186 
190 
191 #ifndef OMWi_DOXYGEN_PREDEFINE
192 
193 #ifdef OMW_CXX_MSVC
194 #define OMW_CPPSTD (_MSVC_LANG)
195 #else // _MSC_VER
196 #define OMW_CPPSTD (__cplusplus)
197 #endif // _MSC_VER
198 
199 #else // OMWi_DOXYGEN_PREDEFINE
200 #define OMW_CPPSTD
201 #endif // OMWi_DOXYGEN_PREDEFINE
202 
203 
204 
205 #define OMW_CPPSTD_98 (199711L)
206 #define OMW_CPPSTD_11 (201103L)
207 #define OMW_CPPSTD_14 (201402L)
208 #define OMW_CPPSTD_17 (201703L)
209 #define OMW_CPPSTD_20 (202002L)
210 
214 #define OMW_CPPSTD_23 (202100L)
215 
217 
218 
222 
223 #ifdef _DEBUG
224 #define OMW_DEBUG (1)
225 #endif // _DEBUG
226 
227 #if (OMW_CPPSTD >= OMW_CPPSTD_14)
228 #define OMW__FILENAME__ (OMWi_file_to_filename(__FILE__))
229 #endif
230 
231 #ifdef OMWi_DOXYGEN_PREDEFINE
232 #define OMW_DEBUG (1)
233 #define OMW__FILENAME__
234 #endif // OMWi_DOXYGEN_PREDEFINE
235 
237 
244 //##############################################################################
245 //
246 // Things below might not be of interest for users
247 //
248 //##############################################################################
249 
250 
251 
252 //==============================================================================
253 //
254 // internal
255 //
256 
257 #ifndef OMWi_DOXYGEN_PREDEFINE
258 
259 #define OMWi_DISPSTR(x) (x)
260 
261 #ifdef OMW__FILENAME__
262 constexpr const char* OMWi_file_to_filename(const char* p)
263 {
264  const char* fn = p;
265  while (*p)
266  {
267 #if defined(OMW_PLAT_WIN)
268  if (*p++ == '\\') fn = p;
269 #else
270  if (*p++ == '/') fn = p;
271 #endif
272  }
273  return fn;
274 }
275 #endif // OMW__FILENAME__
276 
277 #endif // OMWi_DOXYGEN_PREDEFINE
278 
279 
280 
281 //==============================================================================
282 //
283 // doc
284 //
285 
286 
327 #endif // IG_OMW_DEFS_H