OnixS C++ CME MDP Premium Market Data Handler 5.9.2
Users' manual and 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_CMEMDH_DOXYGEN) && ONIXS_CMEMDH_DOXYGEN)
23
24#include <OnixS/CME/MDH/CompilerDetection.h>
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_CMEMDH_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_CMEMDH_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_CMEMDH_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_CMEMDH_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 <terminate_compilation>
62#endif
63
64# if defined(ONIXS_CMEMDH_COMPILER_IS_GNU) | defined(ONIXS_CMEMDH_COMPILER_IS_Clang)
65# define ONIXS_CMEMDH_COMPILER_IS_GNU_or_Clang
66# endif
67
68
69#define ONIXS_CMEMDH_CONCATENATE_IMPL(X,Y) X##Y
70#define ONIXS_CMEMDH_CONCATENATE(X,Y) ONIXS_CMEMDH_CONCATENATE_IMPL(X,Y)
71
72#if defined(ONIXS_CMEMDH_COMPILER_IS_Clang)
73#define ONIXS_CMEMDH_PADDING(size) __attribute__((__unused__)) char ONIXS_CMEMDH_CONCATENATE(padding, __LINE__)[size]
74#else
75#define ONIXS_CMEMDH_PADDING(size) char ONIXS_CMEMDH_CONCATENATE(padding, __LINE__)[size]
76#endif
77
78
79# if defined(ONIXS_CMEMDH_COMPILER_IS_GNU_or_Clang)
80
81# define ONIXS_CMEMDH_LIKELY(cond) (__builtin_expect((static_cast<bool>((cond))), true))
82# define ONIXS_CMEMDH_UNLIKELY(cond) (__builtin_expect((static_cast<bool>((cond))), false))
83# define ONIXS_CMEMDH_UNUSED __attribute__((__unused__))
84# define ONIXS_CMEMDH_MAY_ALIAS __attribute__((__may_alias__))
85# define ONIXS_CMEMDH_HOTPATH __attribute__((hot))
86# define ONIXS_CMEMDH_COLDPATH __attribute__((noinline,cold))
87# define ONIXS_CMEMDH_NORETURN __attribute__ ((__noreturn__))
88# define ONIXS_CMEMDH_NODISCARD __attribute__((warn_unused_result))
89# define ONIXS_CMEMDH_PURE
90
91#elif defined(ONIXS_CMEMDH_COMPILER_IS_MSVC)
92
93# define ONIXS_CMEMDH_LIKELY(cond) ((cond))
94# define ONIXS_CMEMDH_UNLIKELY(cond) ((cond))
95# define ONIXS_CMEMDH_PURE
96# define ONIXS_CMEMDH_UNUSED
97# define ONIXS_CMEMDH_MAY_ALIAS
98# define ONIXS_CMEMDH_HOTPATH
99# define ONIXS_CMEMDH_COLDPATH
100# define ONIXS_CMEMDH_NORETURN __declspec(noreturn)
101# define ONIXS_CMEMDH_NODISCARD _Check_return_
102
103#else
104# error Unsupported compiler
105#endif
106
107#if defined(ONIXS_CMEMDH_CXX11)
108
109# define ONIXS_CMEMDH_NOEXCEPT noexcept
110# define ONIXS_CMEMDH_CHECK_NOTHROW(equation) ONIXS_CMEMDH_STATIC_ASSERT(noexcept((equation)))
111# define ONIXS_CMEMDH_EXPLICIT explicit
112# define ONIXS_CMEMDH_CONST_OR_CONSTEXPR constexpr
113# define ONIXS_CMEMDH_FINAL final
114# define ONIXS_CMEMDH_OVERRIDE override
115# define ONIXS_CMEMDH_CONSTEXPR constexpr
116# define ONIXS_CMEMDH_NULLPTR nullptr
117# define ONIXS_CMEMDH_DELETED_FUNCTION = delete
118# define ONIXS_CMEMDH_STATIC_ASSERT(X) static_assert(X, #X)
119# define ONIXS_CMEMDH_STATIC_ASSERT_MSG(X, MSG) static_assert(X, MSG)
120# define ONIXS_CMEMDH_ALIGNAS(X) alignas(X)
121# define ONIXS_CMEMDH_DEFAULT =default
122
123#else
124
125# define ONIXS_CMEMDH_NOEXCEPT throw()
126# define ONIXS_CMEMDH_CHECK_NOTHROW(equation) ONIXS_CMEMDH_STATIC_ASSERT((true))
127# define ONIXS_CMEMDH_EXPLICIT
128# define ONIXS_CMEMDH_CONST_OR_CONSTEXPR const
129# define ONIXS_CMEMDH_FINAL
130# define ONIXS_CMEMDH_OVERRIDE
131# define ONIXS_CMEMDH_CONSTEXPR
132# define ONIXS_CMEMDH_DELETED_FUNCTION
133# define ONIXS_CMEMDH_DEFAULT {}
134
135
136# if defined ONIXS_CMEMDH_COMPILER_IS_GNU_or_Clang
137# define ONIXS_CMEMDH_NULLPTR __null
138# else
139# define ONIXS_CMEMDH_NULLPTR 0
140# endif
141
142
143# define ONIXS_CMEMDH_STATIC_ASSERT_JOIN(X, Y) ONIXS_CMEMDH_STATIC_ASSERT_JOIN_IMPL(X, Y)
144# define ONIXS_CMEMDH_STATIC_ASSERT_JOIN_IMPL(X, Y) X##Y
145template<bool> struct ONIXS_ILINK3StaticAssert;
146template<> struct ONIXS_ILINK3StaticAssert<true>{};
147# define ONIXS_CMEMDH_STATIC_ASSERT(X) enum { ONIXS_CMEMDH_STATIC_ASSERT_JOIN(ONIXS_ILINK3StaticAssertEnum, __LINE__) = sizeof(ONIXS_ILINK3StaticAssert<X>) }
148# define ONIXS_CMEMDH_STATIC_ASSERT_MSG(X, MSG) enum { ONIXS_CMEMDH_STATIC_ASSERT_JOIN(ONIXS_ILINK3StaticAssertEnum, __LINE__) = sizeof(ONIXS_ILINK3StaticAssert<X>) }
149
150
151# if defined ONIXS_CMEMDH_COMPILER_IS_GNU_or_Clang
152# define ONIXS_CMEMDH_ALIGNAS(X) __attribute__ ((__aligned__(X)))
153# elif defined ONIXS_CMEMDH_COMPILER_IS_MSVC
154# define ONIXS_CMEMDH_ALIGNAS(X) __declspec(align(X))
155# else
156# define ONIXS_CMEMDH_ALIGNAS(X)
157# endif
158
159#endif
160
161#if defined NDEBUG
162# define ONIXS_CMEMDH_ASSERT(CHECK) static_cast<void>((CHECK))
163#else
164#if defined (ONIXS_CMEMDH_CXX11)
165# define ONIXS_CMEMDH_ASSERT(CHECK) ((CHECK) ? void(0) : []() {assert(!#CHECK);}())
166# else
167# define ONIXS_CMEMDH_ASSERT(CHECK) (assert((CHECK)))
168# endif
169#endif
170
171#if defined (ONIXS_CMEMDH_CXX11)
172# define ONIXS_CMEMDH_HAS_TYPE_TRAITS
173#endif
174
175#define ONIXS_CMEMDH_HARDWARE_DESTRUCTIVE_INTERFACE_SIZE (64)
176
177#else //#if !(defined(ONIXS_DOXYGEN) && ONIXS_DOXYGEN)
178
179#define ONIXS_CMEMDH_EXPORTED
180#define ONIXS_CMEMDH_NOEXCEPT noexcept
181#define ONIXS_CMEMDH_EXPLICIT explicit
182#define ONIXS_CMEMDH_CONST_OR_CONSTEXPR constexpr
183#define ONIXS_CMEMDH_CONSTEXPR constexpr
184#define ONIXS_CMEMDH_OVERRIDE override
185#define ONIXS_CMEMDH_FINAL final
186#define ONIXS_CMEMDH_NULLPTR nullptr
187
188#define ONIXS_CMEMDH_NORETURN
189#define ONIXS_CMEMDH_NODISCARD
190
191#define ONIXS_CMEMDH_HOTPATH
192#define ONIXS_CMEMDH_COLDPATH
193#define ONIXS_CMEMDH_PURE
194
195#define ONIXS_CMEMDH_HAS_TYPE_TRAITS
196
197#define ONIXS_CMEMDH_HAS_GATEWAY_EMULATOR
198
199#define ONIXS_CMEMDH_CXX11
200#define ONIXS_CMEMDH_CXX14
201#define ONIXS_CMEMDH_CXX17
202#define ONIXS_CMEMDH_CXX20
203
204
205#define ONIXS_CMEMDH_UNUSED
206#define ONIXS_CMEMDH_DEFAULT =default
207
208#endif