OnixS C++ CME MDP Premium Market Data Handler 5.10.3
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#include <OnixS/CME/MDH/Export.h>
26
27#if defined(_MSC_VER) && defined(_MSVC_LANG)
28# define ONIXS_CURRENT_CXX_STD _MSVC_LANG
29#else
30# define ONIXS_CURRENT_CXX_STD __cplusplus
31#endif
32
33# if !defined(ONIXS_CMEMDH_CXX11) || (ONIXS_CURRENT_CXX_STD < 201103L)
34# error At least C++11 is required to build this project
35# define ONIXS_TERMINATE_COMPILATION
36#endif
37
38# if defined(ONIXS_CMEMDH_CXX14)
39# if (ONIXS_CURRENT_CXX_STD < 201402L)
40# error C++14 was targeted during the OnixS SDK compilation but is not detected now
41# define ONIXS_TERMINATE_COMPILATION
42# endif
43# endif
44
45# if defined(ONIXS_CMEMDH_CXX17)
46# if (ONIXS_CURRENT_CXX_STD < 201703L)
47# error C++17 was targeted during the OnixS SDK compilation but is not detected now
48# define ONIXS_TERMINATE_COMPILATION
49# endif
50# endif
51
52# if defined(ONIXS_CMEMDH_CXX20)
53# if !(ONIXS_CURRENT_CXX_STD > 201703L)
54# error C++20 was targeted during the OnixS SDK compilation but is not detected now
55# define ONIXS_TERMINATE_COMPILATION
56# endif
57# endif
58
59# if defined(ONIXS_TERMINATE_COMPILATION)
60# include <terminate_compilation>
61#endif
62
63# if defined(ONIXS_CMEMDH_COMPILER_IS_GNU) | defined(ONIXS_CMEMDH_COMPILER_IS_Clang)
64# define ONIXS_CMEMDH_COMPILER_IS_GNU_or_Clang
65# endif
66
67#define ONIXS_CMEMDH_TO_STR_IMPL(x) #x
68#define ONIXS_CMEMDH_TO_STR(x) ONIXS_CMEMDH_TO_STR_IMPL(x)
69
70#define ONIXS_CMEMDH_CONCATENATE_IMPL(X,Y) X##Y
71#define ONIXS_CMEMDH_CONCATENATE(X,Y) ONIXS_CMEMDH_CONCATENATE_IMPL(X,Y)
72
73#if defined(ONIXS_CMEMDH_COMPILER_IS_Clang)
74#define ONIXS_CMEMDH_PADDING(size) __attribute__((__unused__)) char ONIXS_CMEMDH_CONCATENATE(padding, __LINE__)[size]
75#else
76#define ONIXS_CMEMDH_PADDING(size) char ONIXS_CMEMDH_CONCATENATE(padding, __LINE__)[size]
77#endif
78
79#if defined ONIXS_CMEMDH_ENABLE_DEPRECATED_WARNING
80#if defined(ONIXS_CMEMDH_CXX14)
81# define ONIXS_CMEMDH_DEPRECATED [[deprecated]]
82# else
83# define ONIXS_CMEMDH_DEPRECATED ONIXS_CMEMDH_DEPRECATED_IMPL
84# endif
85#else
86# define ONIXS_CMEMDH_DEPRECATED /**/
87#endif
88
89# if !defined ONIXS_CMEMDH_ENABLE_DEPRECATED_WARNING
90# define ONIXS_CMEMDH_DEPRECATED_HEADER(msg) /**/
91# endif
92
93# if defined(ONIXS_CMEMDH_COMPILER_IS_GNU_or_Clang)
94
95# define ONIXS_CMEMDH_LIKELY(cond) (__builtin_expect((static_cast<bool>((cond))), true))
96# define ONIXS_CMEMDH_UNLIKELY(cond) (__builtin_expect((static_cast<bool>((cond))), false))
97# define ONIXS_CMEMDH_UNUSED __attribute__((__unused__))
98# define ONIXS_CMEMDH_MAY_ALIAS __attribute__((__may_alias__))
99# define ONIXS_CMEMDH_HOTPATH __attribute__((hot))
100# define ONIXS_CMEMDH_COLDPATH __attribute__((noinline,cold))
101# define ONIXS_CMEMDH_NORETURN __attribute__ ((__noreturn__))
102# define ONIXS_CMEMDH_NODISCARD __attribute__((warn_unused_result))
103# define ONIXS_CMEMDH_FORCEINLINE inline __attribute__ ((__always_inline__))
104# define ONIXS_CMEMDH_PURE
105
106# define ONIXS_CMEMDH_PRAGMA(x) _Pragma(#x)
107
108# if defined ONIXS_CMEMDH_ENABLE_DEPRECATED_WARNING
109# define ONIXS_CMEMDH_DEPRECATED_HEADER(msg) ONIXS_CMEMDH_PRAGMA(GCC warning msg)
110# endif
111
112# define ONIXS_CMEMDH_DISABLE_DEPRECATED_WARNINGS ONIXS_CMEMDH_PRAGMA(GCC diagnostic push) ONIXS_CMEMDH_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations")
113# define ONIXS_CMEMDH_DISABLE_DEPRECATED_WARNINGS_END ONIXS_CMEMDH_PRAGMA(GCC diagnostic pop)
114
115#elif defined(ONIXS_CMEMDH_COMPILER_IS_MSVC)
116
117# define ONIXS_CMEMDH_LIKELY(cond) ((cond))
118# define ONIXS_CMEMDH_UNLIKELY(cond) ((cond))
119# define ONIXS_CMEMDH_PURE
120# define ONIXS_CMEMDH_UNUSED
121# define ONIXS_CMEMDH_MAY_ALIAS
122# define ONIXS_CMEMDH_HOTPATH
123# define ONIXS_CMEMDH_COLDPATH
124# define ONIXS_CMEMDH_NORETURN __declspec(noreturn)
125# define ONIXS_CMEMDH_NODISCARD _Check_return_
126# define ONIXS_CMEMDH_FORCEINLINE inline
127# define ONIXS_CMEMDH_PRAGMA(x) __pragma(x)
128
129# if defined ONIXS_CMEMDH_ENABLE_DEPRECATED_WARNING
130# define ONIXS_CMEMDH_DEPRECATED_HEADER(msg) ONIXS_CMEMDH_PRAGMA(message(__FILE__ "(" ONIXS_CMEMDH_TO_STR(__LINE__) "): " msg))
131# endif
132
133# define ONIXS_CMEMDH_DISABLE_DEPRECATED_WARNINGS ONIXS_CMEMDH_PRAGMA(warning(push)) ONIXS_CMEMDH_PRAGMA(warning(disable: 4996))
134# define ONIXS_CMEMDH_DISABLE_DEPRECATED_WARNINGS_END ONIXS_CMEMDH_PRAGMA(warning(pop))
135
136#else
137# error Unsupported compiler
138#endif
139
140#if defined NDEBUG
141# define ONIXS_CMEMDH_ASSERT(CHECK) static_cast<void>((CHECK))
142#else
143# define ONIXS_CMEMDH_ASSERT(CHECK) ((CHECK) ? void(0) : []() {assert(!#CHECK);}())
144#endif
145
146#else //#if !(defined(ONIXS_DOXYGEN) && ONIXS_DOXYGEN)
147
148#define ONIXS_CMEMDH_EXPORTED
149#define ONIXS_CMEMDH_NORETURN
150#define ONIXS_CMEMDH_NODISCARD
151
152#define ONIXS_CMEMDH_HOTPATH
153#define ONIXS_CMEMDH_COLDPATH
154#define ONIXS_CMEMDH_PURE
155
156#define ONIXS_CMEMDH_CXX11
157#define ONIXS_CMEMDH_CXX14
158#define ONIXS_CMEMDH_CXX17
159#define ONIXS_CMEMDH_CXX20
160
161#define ONIXS_CMEMDH_FORCEINLINE
162#define ONIXS_CMEMDH_UNUSED
163
164#define ONIXS_CMEMDH_PRAGMA(x)
165#define ONIXS_CMEMDH_MESSAGING_NO_DEPRECATED
166#define ONIXS_CMEMDH_NO_DEPRECATED
167#define ONIXS_CMEMDH_DEPRECATED
168#define ONIXS_CMEMDH_DEPRECATED_HEADER(msg)
169
170#define ONIXS_CMEMDH_DISABLE_DEPRECATED_WARNINGS
171#define ONIXS_CMEMDH_DISABLE_DEPRECATED_WARNINGS_END
172
173#endif
174
175#define ONIXS_CMEMDH_DATA_PACKING_BEGIN(alignment) ONIXS_CMEMDH_PRAGMA(pack(push, alignment))
176#define ONIXS_CMEMDH_DATA_PACKING_END ONIXS_CMEMDH_PRAGMA(pack(pop))
177
178#define ONIXS_CMEMDH_PUSH_MACRO(name) ONIXS_CMEMDH_PRAGMA(push_macro(name))
179#define ONIXS_CMEMDH_POP_MACRO(name) ONIXS_CMEMDH_PRAGMA(pop_macro(name))