-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.cpccIdeMacros.h
178 lines (141 loc) · 4.75 KB
/
core.cpccIdeMacros.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/* *****************************************
* File: cpccDefines.h
* Purpose: Portable (cross-platform), light-weight, library
* *****************************************
* Library: Cross Platform C++ Classes (cpcc)
* Copyright: 2018 StarMessage software.
* License: Free for opensource projects.
* Commercial license exists for closed source projects.
* Web: http://www.StarMessageSoftware.com/cpcclibrary
* Download: https://code.google.com/p/cpcc/
* email: sales -at- starmessage.info
* *****************************************
*/
#pragma once
// https://msdn.microsoft.com/en-us/library/b0084kay.aspx
// Visual Studio: _DEBUG Defined as 1 when the /LDd, /MDd, or /MTd compiler option is set. Otherwise, undefined.
// NDEBUG disables standard-C assertions
// Use them when apropriate,
// ie _DEBUG if you want your debugging code to be consistent with the MS CRT debugging techniques and
// NDEBUG if you want to be consistent with assert().
// xcode: In iOS, in debug mode, the DEBUG preprocessor directive is defined
// In MacOS, DEBUG=1
#ifdef _DEBUG
#define cpccDEBUG
#endif
#ifdef DEBUG
#define cpccDEBUG
#endif
#ifdef NDEBUG
#undef cpccDEBUG
#endif
#ifdef __APPLE__
#ifndef NDEBUG // in xcode put NDEBUG in the release configuration
// #define cpccDEBUG
#endif
#endif
// //////////////////////////////////
// 32 vs 64 bits
// //////////////////////////////////
// Check windows
#if _WIN32 || _WIN64
#if _WIN64
#define COMPILED64BIT
#else
#define COMPILED32BIT
#endif
#endif
// This works for MSVC++ and g++ :
// #if defined(_M_X64) || defined(__amd64__)
// Check GCC
#if __GNUC__
#if __x86_64__ || __ppc64__
#define COMPILED64BIT
#else
#define COMPILED32BIT
#endif
#endif
// http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
// suggests __LP64__ and _LP64
/* another way for all compilers
// C
#include <stdint.h>
// C++
#include <cstdint>
#if INTPTR_MAX == INT64_MAX
// 64-bit
#elif INTPTR_MAX == INT32_MAX
// 32-bit
#else
#error Unknown pointer size or missing size macros!
#endif
*/
/*
From TargetConditionals.h:
TARGET_OS_WIN32 - Generated code will run under 32-bit Windows
TARGET_OS_UNIX - Generated code will run under some Unix (not OSX)
TARGET_OS_MAC - Generated code will run under Mac OS X variant
TARGET_OS_IPHONE - Generated code for firmware, devices, or simulator
TARGET_OS_IOS - Generated code will run under iOS
TARGET_OS_TV - Generated code will run under Apple TV OS
TARGET_OS_WATCH - Generated code will run under Apple Watch OS
TARGET_OS_SIMULATOR - Generated code will run under a simulator
TARGET_OS_EMBEDDED - Generated code for firmware
TARGET_IPHONE_SIMULATOR - DEPRECATED: Same as TARGET_OS_SIMULATOR
TARGET_OS_NANO - DEPRECATED: Same as TARGET_OS_WATCH
+------------------------------------------------+
| TARGET_OS_MAC |
| +---+ +-------------------------------------+ |
| | | | TARGET_OS_IPHONE | |
| |OSX| | +-----+ +----+ +-------+ +--------+ | |
| | | | | IOS | | TV | | WATCH | | BRIDGE | | |
| | | | +-----+ +----+ +-------+ +--------+ | |
| +---+ +-------------------------------------+ |
+------------------------------------------------+
*/
// target platform
#ifdef _WIN32 // covers 32-bit and 64-bit
#define cpccTARGET_WINDOWS
#ifdef _WIN64
#define cpccTARGET_WINDOWS64
#else
#define cpccTARGET_WINDOWS32
#endif
#endif
#if __APPLE__ // This macro is defined in any Apple computer.
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE
#define cpccTARGET_IOS
#elif TARGET_OS_MAC
#define cpccTARGET_MACOS
#else
#error "cpccIdeMacros: Unknown Apple platform"
#endif
#endif
#if defined(ANDROID) || defined(__ANDROID__) // both needed
#define cpccTARGET_ANDROID
#endif
class cppcIDE
{
public:
// http://nadeausoftware.com/articles/2012/10/c_c_tip_how_detect_compiler_name_and_version_using_compiler_predefined_macros
static const char *getCompilerVersion(void)
{
#if __cplusplus == 201703L
return "2017 C++ standard";
#endif
#if __cplusplus == 201402L
return "2014 C++ standard";
#endif
#if __cplusplus == 201103L
return "2011 C++ standard";
#endif
#if __cplusplus == 199711L
return "1998 C++ standard";
#endif
#ifdef __STDC_VERSION__
return __STDC_VERSION__;
#endif
return "Undetected compiler version";
}
};