forked from Alinshans/MyTinySTL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
platform.h
108 lines (84 loc) · 2.91 KB
/
platform.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
// ============================================================================
// Copyright (c) 2017 Alinshans. All rights reserved.
// Licensed under the MIT License. See LICENSE for details.
//
// Header File : redbud/platform.h
//
// This file contains some preprocessing macros related to the platform.
// ============================================================================
#ifndef ALINSHANS_REDBUD_PLATFORM_H_
#define ALINSHANS_REDBUD_PLATFORM_H_
// ----------------------------------------------------------------------------
// os
#if defined(WIN32) || defined(_WIN32) || defined(_WIN64)
#define REDBUD_WIN 1
#elif defined(__unix__) || defined(__unix) || defined(__linux__)
#define REDBUD_LINUX 1
#elif defined(__APPLE__) || defined(__MACH__)
#define REDBUD_OSX 1
#else
#error "System that is not supported yet."
#endif
// ----------------------------------------------------------------------------
// complier
#if defined(__clang__)
#define REDBUD_CLANG __clang__
#elif defined(__GNUC__)
#define REDBUD_GNUC __GNUC__
#elif defined(_MSC_VER)
#define REDBUD_MSVC _MSC_VER
#else
#error "Complier that is not supported yet."
#endif
// ----------------------------------------------------------------------------
// stringify
#define REDBUD_TO_STRING(x) #x
#define REDBUD_STRING(x) REDBUD_TO_STRING(x)
// ----------------------------------------------------------------------------
// join
#define REDBUD_DO_JOIN(x ,y) x##y
#define REDBUD_JOIN(x, y) REDBUD_DO_JOIN(x, y)
// ----------------------------------------------------------------------------
// version
#define REDBUD_MAJOR 1
#define REDBUD_MINOR 0
#define REDBUD_PATCH 0
#define REDBUD_VERSION \
REDBUD_STRING(REDBUD_MAJOR.REDBUD_MINOR.REDBUD_PATCH)
#define _VERSION_CODE(x,y,z) \
(((x)*100000) + ((y)*100) + (z))
#define GNUC_VERSION \
_VERSION_CODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
#define CLANG_VERSION \
_VERSION_CODE(__clang_major__, __clang_minor__, __clang_patchlevel__)
// ----------------------------------------------------------------------------
// redbud API
#ifndef _REDBUD_API
#define _REDBUD_API ::redbud::
#endif
// ----------------------------------------------------------------------------
// C++11 required
#ifndef REDBUD_HAS_CXX11
#if defined(REDBUD_MSVC) && (REDBUD_MSVC >= 1900)
#define REDBUD_HAS_CXX11 1
#elif defined(REDBUD_GNUC) && (GNUC_VERSION >= _VERSION_CODE(4,8,0)) && \
defined(__GXX_EXPERIMENTAL_CXX0X__)
#define REDBUD_HAS_CXX11 1
#elif defined(REDBUD_CLANG) && (CLANG_VERSION >= _VERSION_CODE(3,3,0))
#define REDBUD_HAS_CXX11 1
#else
#define REDBUD_HAS_CXX11 0
#endif
#endif // !REDBUD_HAS_CXX11
#if REDBUD_HAS_CXX11 == 0
#error "C++11 required."
#endif
// ----------------------------------------------------------------------------
// Undefines macro min and max in MSVC.
namespace redbud
{
#if REDBUD_MSVC
#define NOMINMAX
#endif
}
#endif // !ALINSHANS_REDBUD_PLATFORM_H_