OnixS C++ FIX Engine 4.13.0
API Documentation
Loading...
Searching...
No Matches
Compiler.h
Go to the documentation of this file.
1/*
2* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3*
4* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5* and international copyright treaties.
6*
7* Access to and use of the software is governed by the terms of the applicable ONIXS Software
8* Services Agreement (the Agreement) and Customer end user license agreements granting
9* a non-assignable, non-transferable and non-exclusive license to use the software
10* for it's own data processing purposes under the terms defined in the Agreement.
11*
12* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13* of this source code or associated reference material to any other location for further reproduction
14* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15*
16* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17* the terms of the Agreement is a violation of copyright law.
18*/
19
20#pragma once
21
22#if !(defined(ONIXS_FIXENGINE_DOXYGEN) && ONIXS_FIXENGINE_DOXYGEN)
23
25
26#if defined(_MSC_VER) && defined(_MSVC_LANG)
27# define ONIXS_CURRENT_CXX_STD _MSVC_LANG
28#else
29# define ONIXS_CURRENT_CXX_STD __cplusplus
30#endif
31
32# if defined(ONIXS_FIXENGINE_CXX11)
33# if (ONIXS_CURRENT_CXX_STD < 201103L)
34# error C++11 was targeted during the OnixS SDK compilation but is not detected now
35# define ONIXS_TERMINATE_COMPILATION
36# endif
37# endif
38
39# if defined(ONIXS_FIXENGINE_CXX14)
40# if (ONIXS_CURRENT_CXX_STD < 201402L)
41# error C++14 was targeted during the OnixS SDK compilation but is not detected now
42# define ONIXS_TERMINATE_COMPILATION
43# endif
44# endif
45
46# if defined(ONIXS_FIXENGINE_CXX17)
47# if (ONIXS_CURRENT_CXX_STD < 201703L)
48# error C++17 was targeted during the OnixS SDK compilation but is not detected now
49# define ONIXS_TERMINATE_COMPILATION
50# endif
51# endif
52
53# if defined(ONIXS_FIXENGINE_CXX20)
54# if !(ONIXS_CURRENT_CXX_STD > 201703L)
55# error C++20 was targeted during the OnixS SDK compilation but is not detected now
56# define ONIXS_TERMINATE_COMPILATION
57# endif
58# endif
59
60# if defined(ONIXS_TERMINATE_COMPILATION)
61# include <termnate_compilation>
62#endif
63
64# if defined(ONIXS_FIXENGINE_COMPILER_IS_GNU) | defined(ONIXS_FIXENGINE_COMPILER_IS_Clang)
65# define ONIXS_FIXENGINE_COMPILER_IS_GNU_or_Clang
66# endif
67
68#if !defined ONIXS_FIXENGINE_COMPILER_IS_GNU
69# if defined(__has_cpp_attribute)
70# if __has_cpp_attribute(likely)
71# define ONIXS_FIXENGINE_LIKELY_ATTR [[likely]]
72# define ONIXS_FIXENGINE_LIKELY(cond) ((cond)) [[likely]]
73# endif
74# if __has_cpp_attribute(unlikely)
75# define ONIXS_FIXENGINE_UNLIKELY_ATTR [[unlikely]]
76# define ONIXS_FIXENGINE_UNLIKELY(cond) ((cond)) [[unlikely]]
77# endif
78# if __has_cpp_attribute(noreturn)
79# define ONIXS_FIXENGINE_NORETURN [[noreturn]]
80# endif
81# if __has_cpp_attribute(nodiscard)
82# define ONIXS_FIXENGINE_NODISCARD [[nodiscard]]
83# endif
84# endif
85#endif
86
87# if defined(ONIXS_FIXENGINE_COMPILER_IS_GNU_or_Clang)
88
89# if !defined ONIXS_FIXENGINE_LIKELY
90# define ONIXS_FIXENGINE_LIKELY(cond) (__builtin_expect((static_cast<bool>((cond))), true))
91# endif
92
93# if !defined ONIXS_FIXENGINE_LIKELY_ATTR
94# define ONIXS_FIXENGINE_LIKELY_ATTR
95# endif
96
97# if !defined ONIXS_FIXENGINE_UNLIKELY
98# define ONIXS_FIXENGINE_UNLIKELY(cond) (__builtin_expect((static_cast<bool>((cond))), false))
99# endif
100
101# if !defined ONIXS_FIXENGINE_UNLIKELY_ATTR
102# define ONIXS_FIXENGINE_UNLIKELY_ATTR
103# endif
104
105# if !defined ONIXS_FIXENGINE_NORETURN
106# define ONIXS_FIXENGINE_NORETURN __attribute__ ((__noreturn__))
107# endif
108
109# if !defined ONIXS_FIXENGINE_NODISCARD
110# define ONIXS_FIXENGINE_NODISCARD __attribute__((warn_unused_result))
111# endif
112
113# define ONIXS_FIXENGINE_UNUSED __attribute__((__unused__))
114# define ONIXS_FIXENGINE_MAY_ALIAS __attribute__((__may_alias__))
115# define ONIXS_FIXENGINE_HOTPATH __attribute__((hot))
116# define ONIXS_FIXENGINE_COLDPATH __attribute__((noinline,cold))
117# define ONIXS_FIXENGINE_PURE __attribute__((pure))
118
119#elif defined(ONIXS_FIXENGINE_COMPILER_IS_MSVC)
120
121# if !defined ONIXS_FIXENGINE_LIKELY
122# define ONIXS_FIXENGINE_LIKELY(cond) ((cond))
123# endif
124
125# if !defined ONIXS_FIXENGINE_LIKELY_ATTR
126# define ONIXS_FIXENGINE_LIKELY_ATTR
127# endif
128
129# if !defined ONIXS_FIXENGINE_UNLIKELY
130# define ONIXS_FIXENGINE_UNLIKELY(cond) ((cond))
131# endif
132
133# if !defined ONIXS_FIXENGINE_UNLIKELY_ATTR
134# define ONIXS_FIXENGINE_UNLIKELY_ATTR
135# endif
136
137# if !defined ONIXS_FIXENGINE_NORETURN
138# define ONIXS_FIXENGINE_NORETURN __declspec(noreturn)
139# endif
140
141# if !defined ONIXS_FIXENGINE_NODISCARD
142# define ONIXS_FIXENGINE_NODISCARD _Check_return_
143# endif
144
145# define ONIXS_FIXENGINE_PURE
146# define ONIXS_FIXENGINE_UNUSED
147# define ONIXS_FIXENGINE_MAY_ALIAS
148# define ONIXS_FIXENGINE_HOTPATH
149# define ONIXS_FIXENGINE_COLDPATH __declspec(noinline)
150
151#else
152# error Unsupported compiler
153#endif
154
155#if defined(ONIXS_FIXENGINE_COMPILER_IS_GNU)
156# define ONIXS_FIXENGINE_CHECK_EXPECT(exp,c) (__builtin_expect((exp), (c)))
157#else
158# define ONIXS_FIXENGINE_CHECK_EXPECT(exp,c) ((exp))
159#endif
160
161# if defined(ONIXS_FIXENGINE_COMPILER_IS_GNU) & !defined(ONIXS_FIXENGINE_CXX11)
162# define ONIXS_FIXENGINE_GCC44_SPURIOUS_WARNING_TURNAROUND ONIXS_FIXENGINE_MAY_ALIAS
163# else
164# define ONIXS_FIXENGINE_GCC44_SPURIOUS_WARNING_TURNAROUND
165# endif
166
167
168#if defined(ONIXS_FIXENGINE_CXX11)
169
170# define ONIXS_FIXENGINE_NOTHROW noexcept
171# define ONIXS_FIXENGINE_CHECK_NOTHROW(equation) ONIXS_FIXENGINE_STATIC_ASSERT(noexcept((equation)))
172# define ONIXS_FIXENGINE_EXPLICIT explicit
173# define ONIXS_FIXENGINE_CONST_OR_CONSTEXPR constexpr
174# define ONIXS_FIXENGINE_FINAL final
175# define ONIXS_FIXENGINE_OVERRIDE override
176# define ONIXS_FIXENGINE_CONSTEXPR constexpr
177# define ONIXS_FIXENGINE_NULLPTR nullptr
178# define ONIXS_FIXENGINE_DELETED_FUNCTION = delete
179# define ONIXS_FIXENGINE_STATIC_ASSERT(X) static_assert(X, #X)
180# define ONIXS_FIXENGINE_STATIC_ASSERT_MSG(X, MSG) static_assert(X, MSG)
181# define ONIXS_FIXENGINE_ALIGNAS(X) alignas(X)
182# define ONIXS_FIXENGINE_DEFAULT =default
183
184#else
185
186# define ONIXS_FIXENGINE_NOTHROW throw()
187# define ONIXS_FIXENGINE_CHECK_NOTHROW(equation) ONIXS_FIXENGINE_STATIC_ASSERT((true))
188# define ONIXS_FIXENGINE_EXPLICIT
189# define ONIXS_FIXENGINE_CONST_OR_CONSTEXPR const
190# define ONIXS_FIXENGINE_FINAL
191# define ONIXS_FIXENGINE_OVERRIDE
192# define ONIXS_FIXENGINE_CONSTEXPR
193# define ONIXS_FIXENGINE_DELETED_FUNCTION
194# define ONIXS_FIXENGINE_DEFAULT {}
195
196
197# if defined ONIXS_FIXENGINE_COMPILER_IS_GNU_or_Clang
198# define ONIXS_FIXENGINE_NULLPTR __null
199# else
200# define ONIXS_FIXENGINE_NULLPTR 0
201# endif
202
203
204# define ONIXS_FIXENGINE_STATIC_ASSERT_JOIN(X, Y) ONIXS_FIXENGINE_STATIC_ASSERT_JOIN_IMPL(X, Y)
205# define ONIXS_FIXENGINE_STATIC_ASSERT_JOIN_IMPL(X, Y) X##Y
206template<bool> struct ONIXS_FIXENGINEStaticAssert;
207template<> struct ONIXS_FIXENGINEStaticAssert<true>{};
208# define ONIXS_FIXENGINE_STATIC_ASSERT(X) enum { ONIXS_FIXENGINE_STATIC_ASSERT_JOIN(ONIXS_FIXENGINEStaticAssertEnum, __LINE__) = sizeof(ONIXS_FIXENGINEStaticAssert<X>) }
209# define ONIXS_FIXENGINE_STATIC_ASSERT_MSG(X, MSG) enum { ONIXS_FIXENGINE_STATIC_ASSERT_JOIN(ONIXS_FIXENGINEStaticAssertEnum, __LINE__) = sizeof(ONIXS_FIXENGINEStaticAssert<X>) }
210
211
212# if defined ONIXS_FIXENGINE_COMPILER_IS_GNU_or_Clang
213# define ONIXS_FIXENGINE_ALIGNAS(X) __attribute__ ((__aligned__(X)))
214# elif defined ONIXS_FIXENGINE_COMPILER_IS_MSVC
215# define ONIXS_FIXENGINE_ALIGNAS(X) __declspec(align(X))
216# else
217# define ONIXS_FIXENGINE_ALIGNAS(X)
218# endif
219
220#endif
221
222#if defined NDEBUG
223# define ONIXS_FIXENGINE_ASSERT(CHECK) static_cast<void>((CHECK))
224#else
225#if defined (ONIXS_FIXENGINE_CXX11)
226# define ONIXS_FIXENGINE_ASSERT(CHECK) ((CHECK) ? void(0) : []() {assert(!#CHECK);}())
227# else
228# define ONIXS_FIXENGINE_ASSERT(CHECK) (assert((CHECK)))
229# endif
230#endif
231
232#if defined (ONIXS_FIXENGINE_CXX11)
233# define ONIXS_FIXENGINE_HAS_TYPE_TRAITS
234#endif
235
236#if defined(ONIXS_FIXENGINE_CXX17)
237# define ONIXS_FIXENGINE_HAS_STRING_VIEW
238#endif
239
240#define ONIXS_FIXENGINE_HARDWARE_DESTRUCTIVE_INTERFACE_SIZE (64)
241
242#else //#if !(defined(ONIXS_DOXYGEN) && ONIXS_DOXYGEN)
243
244#define ONIXS_FIXENGINE_EXPORTED
245#define ONIXS_FIXENGINE_NOTHROW noexcept
246#define ONIXS_FIXENGINE_EXPLICIT explicit
247#define ONIXS_FIXENGINE_CONST_OR_CONSTEXPR constexpr
248#define ONIXS_FIXENGINE_CONSTEXPR constexpr
249#define ONIXS_FIXENGINE_OVERRIDE override
250#define ONIXS_FIXENGINE_FINAL final
251#define ONIXS_FIXENGINE_NULLPTR nullptr
252
253#define ONIXS_FIXENGINE_NORETURN
254#define ONIXS_FIXENGINE_NODISCARD
255
256#define ONIXS_FIXENGINE_HOTPATH
257#define ONIXS_FIXENGINE_COLDPATH
258#define ONIXS_FIXENGINE_PURE
259
260#define ONIXS_FIXENGINE_HAS_TYPE_TRAITS
261#define ONIXS_FIXENGINE_HAS_STRING_VIEW
262
263#define ONIXS_FIXENGINE_CXX11
264#define ONIXS_FIXENGINE_CXX14
265#define ONIXS_FIXENGINE_CXX17
266#define ONIXS_FIXENGINE_CXX20
267
268
269#define ONIXS_FIXENGINE_UNUSED
270#define ONIXS_FIXENGINE_DEFAULT =default
271
272#define ONIXS_FIXENGINE_GCC44_SPURIOUS_WARNING_TURNAROUND
273
274#endif