Embedded Template Library 1.0
Loading...
Searching...
No Matches
determine_compiler_language_support.h
Go to the documentation of this file.
1
2
3/******************************************************************************
4The MIT License(MIT)
5
6Embedded Template Library.
7https://github.com/ETLCPP/etl
8https://www.etlcpp.com
9
10Copyright(c) 2019 John Wellbelove
11
12Permission is hereby granted, free of charge, to any person obtaining a copy
13of this software and associated documentation files(the "Software"), to deal
14in the Software without restriction, including without limitation the rights
15to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
16copies of the Software, and to permit persons to whom the Software is
17furnished to do so, subject to the following conditions :
18
19The above copyright notice and this permission notice shall be included in all
20copies or substantial portions of the Software.
21
22THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
25AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28SOFTWARE.
29******************************************************************************/
30
31#ifndef ETL_DETERMINE_COMPILER_LANGUAGE_SUPPORT_H_INCLUDED
32#define ETL_DETERMINE_COMPILER_LANGUAGE_SUPPORT_H_INCLUDED
33
34//#include <math.h>
35
36#include "determine_compiler.h"
37
38// Determine C++23 support
39#if !defined(ETL_CPP23_SUPPORTED)
40 #if defined(__cplusplus)
41 #if defined(ETL_COMPILER_MICROSOFT)
42 #define ETL_CPP23_SUPPORTED (__cplusplus >= 202302L)
43 #elif defined(ETL_COMPILER_ARM5)
44 #define ETL_CPP23_SUPPORTED 0
45 #elif defined(ETL_COMPILER_GCC)
46 #define ETL_CPP23_SUPPORTED (__cplusplus >= 202302L)
47 #else
48 #define ETL_CPP23_SUPPORTED (__cplusplus >= 202302L)
49 #endif
50 #else
51 #define ETL_CPP23_SUPPORTED 0
52 #endif
53#endif
54
55#if ETL_CPP23_SUPPORTED
56 #define ETL_CPP11_SUPPORTED 1
57 #define ETL_CPP14_SUPPORTED 1
58 #define ETL_CPP17_SUPPORTED 1
59 #define ETL_CPP20_SUPPORTED 1
60#endif
61
62// Determine C++20 support
63#if !defined(ETL_CPP20_SUPPORTED)
64 #if defined(__cplusplus)
65 #if defined(ETL_COMPILER_MICROSOFT)
66 #if defined(_MSVC_LANG)
67 #define ETL_CPP20_SUPPORTED (_MSVC_LANG >= 202002L)
68 #else
69 #define ETL_CPP20_SUPPORTED (_MSC_VER >= 1929)
70 #endif
71 #elif defined(ETL_COMPILER_ARM5)
72 #define ETL_CPP20_SUPPORTED 0
73 #elif defined(ETL_COMPILER_GCC)
74 #if (__GNUC__ == 10)
75 #define ETL_CPP20_SUPPORTED (__cplusplus >= 201709L)
76 #else
77 #define ETL_CPP20_SUPPORTED (__cplusplus >= 202002L)
78 #endif
79 #else
80 #define ETL_CPP20_SUPPORTED (__cplusplus >= 202002L)
81 #endif
82 #else
83 #define ETL_CPP20_SUPPORTED 0
84 #endif
85#endif
86
87#if ETL_CPP20_SUPPORTED
88 #define ETL_CPP11_SUPPORTED 1
89 #define ETL_CPP14_SUPPORTED 1
90 #define ETL_CPP17_SUPPORTED 1
91#endif
92
93// Determine C++17 support
94#if !defined(ETL_CPP17_SUPPORTED)
95 #if defined(__cplusplus)
96 #if defined(ETL_COMPILER_MICROSOFT)
97 #if defined(_MSVC_LANG)
98 #define ETL_CPP17_SUPPORTED (_MSVC_LANG >= 201703L)
99 #else
100 #define ETL_CPP17_SUPPORTED (_MSC_VER >= 1914)
101 #endif
102 #elif defined(ETL_COMPILER_ARM5)
103 #define ETL_CPP17_SUPPORTED 0
104 #else
105 #define ETL_CPP17_SUPPORTED (__cplusplus >= 201703L)
106 #endif
107 #else
108 #define ETL_CPP17_SUPPORTED 0
109 #endif
110#endif
111
112#if ETL_CPP17_SUPPORTED
113 #define ETL_CPP11_SUPPORTED 1
114 #define ETL_CPP14_SUPPORTED 1
115#endif
116
117// Determine C++14 support
118#if !defined(ETL_CPP14_SUPPORTED)
119 #if defined(__cplusplus)
120 #if defined(ETL_COMPILER_MICROSOFT)
121 #if defined(_MSVC_LANG)
122 #define ETL_CPP14_SUPPORTED (_MSVC_LANG >= 201402L)
123 #else
124 #define ETL_CPP14_SUPPORTED (_MSC_VER >= 1900)
125 #endif
126 #elif defined(ETL_COMPILER_ARM5)
127 #define ETL_CPP14_SUPPORTED 0
128 #else
129 #define ETL_CPP14_SUPPORTED (__cplusplus >= 201402L)
130 #endif
131 #else
132 #define ETL_CPP14_SUPPORTED 0
133 #endif
134#endif
135
136#if ETL_CPP14_SUPPORTED
137 #define ETL_CPP11_SUPPORTED 1
138#endif
139
140// Determine C++11 support
141#if !defined(ETL_CPP11_SUPPORTED)
142 #if defined(__cplusplus)
143 #if defined(ETL_COMPILER_MICROSOFT)
144 #if defined(_MSVC_LANG)
145 #define ETL_CPP11_SUPPORTED (_MSVC_LANG >= 201103L)
146 #else
147 #define ETL_CPP11_SUPPORTED (_MSC_VER >= 1700)
148 #endif
149 #elif defined(ETL_COMPILER_ARM5)
150 #define ETL_CPP11_SUPPORTED 0
151 #else
152 #define ETL_CPP11_SUPPORTED (__cplusplus >= 201103L)
153 #endif
154 #else
155 #define ETL_CPP11_SUPPORTED 0
156 #endif
157#endif
158
159// Helper macros
160#define ETL_CPP11_NOT_SUPPORTED (!ETL_CPP11_SUPPORTED)
161#define ETL_CPP14_NOT_SUPPORTED (!ETL_CPP14_SUPPORTED)
162#define ETL_CPP17_NOT_SUPPORTED (!ETL_CPP17_SUPPORTED)
163#define ETL_CPP20_NOT_SUPPORTED (!ETL_CPP20_SUPPORTED)
164#define ETL_CPP23_NOT_SUPPORTED (!ETL_CPP23_SUPPORTED)
165
166// 'Using' macros
167#define ETL_USING_CPP11 (ETL_CPP11_SUPPORTED == 1)
168#define ETL_USING_CPP14 (ETL_CPP14_SUPPORTED == 1)
169#define ETL_USING_CPP17 (ETL_CPP17_SUPPORTED == 1)
170#define ETL_USING_CPP20 (ETL_CPP20_SUPPORTED == 1)
171#define ETL_USING_CPP23 (ETL_CPP23_SUPPORTED == 1)
172
173#define ETL_NOT_USING_CPP11 (ETL_CPP11_SUPPORTED == 0)
174#define ETL_NOT_USING_CPP14 (ETL_CPP14_SUPPORTED == 0)
175#define ETL_NOT_USING_CPP17 (ETL_CPP17_SUPPORTED == 0)
176#define ETL_NOT_USING_CPP20 (ETL_CPP20_SUPPORTED == 0)
177#define ETL_NOT_USING_CPP23 (ETL_CPP23_SUPPORTED == 0)
178
179#if !defined(ETL_NO_NULLPTR_SUPPORT)
180 #define ETL_NO_NULLPTR_SUPPORT ETL_NOT_USING_CPP11
181#endif
182
183#if !defined(ETL_NO_SMALL_CHAR_SUPPORT)
184 #if ETL_USING_CPP20
185 #define ETL_NO_SMALL_CHAR_SUPPORT 0
186 #else
187 #define ETL_NO_SMALL_CHAR_SUPPORT 1
188 #endif
189#endif
190
191#if !defined(ETL_NO_LARGE_CHAR_SUPPORT)
192 #define ETL_NO_LARGE_CHAR_SUPPORT ETL_NOT_USING_CPP11
193#endif
194
195#if !defined(ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED)
196 #define ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED ETL_USING_CPP11
197#endif
198
199// Language standard
200#if !defined(ETL_LANGUAGE_STANDARD)
201 #if ETL_USING_CPP23
202 #define ETL_LANGUAGE_STANDARD 23
203 #elif ETL_USING_CPP20
204 #define ETL_LANGUAGE_STANDARD 20
205 #elif ETL_USING_CPP17
206 #define ETL_LANGUAGE_STANDARD 17
207 #elif ETL_USING_CPP14
208 #define ETL_LANGUAGE_STANDARD 14
209 #elif ETL_USING_CPP11
210 #define ETL_LANGUAGE_STANDARD 11
211 #else
212 #define ETL_LANGUAGE_STANDARD 3
213 #endif
214#endif
215
216// NAN not defined or Rowley CrossWorks
217#if !defined(ETL_NO_CPP_NAN_SUPPORT) && (!defined(NAN) || defined(__CROSSWORKS_ARM) || defined(ETL_COMPILER_ARM5) || defined(ARDUINO))
218 #define ETL_NO_CPP_NAN_SUPPORT
219#endif
220
221#if defined(__has_include)
222 #if __has_include(<version>)
223 #include <version>
224
225 #if defined(__cpp_lib_byteswap)
226 #if __cpp_lib_byteswap != 0
227 #define ETL_HAS_STD_BYTESWAP 1
228 #endif
229 #endif
230 #endif
231#endif
232#ifndef ETL_HAS_STD_BYTESWAP
233 #define ETL_HAS_STD_BYTESWAP 0
234#endif
235
236#endif