OnixS C++ B3 Binary UMDF Market Data Handler 1.10.0
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_B3_UMDF_MD_DOXYGEN) && ONIXS_B3_UMDF_MD_DOXYGEN)
23
25
26
27#if defined(_MSC_VER) && defined(_MSVC_LANG)
28# define ONIXS_B3_UMDF_MD_CURRENT_CXX_STD _MSVC_LANG
29#else
30# define ONIXS_B3_UMDF_MD_CURRENT_CXX_STD __cplusplus
31#endif
32
33#if !defined(ONIXS_B3_UMDF_MD_CXX11)
34# error at least C++11 is required
35# define ONIXS_TERMINATE_COMPILATION
36# endif
37
38# if defined(ONIXS_B3_UMDF_MD_CXX14)
39# if (ONIXS_B3_UMDF_MD_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_B3_UMDF_MD_CXX17)
46# if (ONIXS_B3_UMDF_MD_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_B3_UMDF_MD_CXX20)
53# if !(ONIXS_B3_UMDF_MD_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#undef ONIXS_B3_UMDF_MD_CURRENT_CXX_STD
64
65# if defined(ONIXS_B3_UMDF_MD_CXX14)
66# define ONIXS_B3_UMDF_MD_CXX14_CONSTEXPR constexpr
67#else
68# define ONIXS_B3_UMDF_MD_CXX14_CONSTEXPR
69# endif
70
71# if defined(ONIXS_B3_UMDF_MD_COMPILER_IS_GNU) | defined(ONIXS_B3_UMDF_MD_COMPILER_IS_Clang)
72# define ONIXS_B3_UMDF_MD_COMPILER_IS_GNU_or_Clang
73# endif
74
75# if defined(ONIXS_B3_UMDF_MD_COMPILER_IS_GNU)
76# if __GNUC__ >= 9 && defined ONIXS_B3_UMDF_MD_CXX14
77# define ONIXS_B3_UMDF_MD_LIKELY(cond) (__builtin_expect_with_probability((static_cast<bool>((cond))), true, 0.99999f))
78# define ONIXS_B3_UMDF_MD_UNLIKELY(cond) (__builtin_expect_with_probability((static_cast<bool>((cond))), false, 0.99999f))
79# else
80# define ONIXS_B3_UMDF_MD_LIKELY(cond) (__builtin_expect((static_cast<bool>((cond))), true))
81# define ONIXS_B3_UMDF_MD_UNLIKELY(cond) (__builtin_expect((static_cast<bool>((cond))), false))
82# endif
83# endif
84
85# if defined(ONIXS_B3_UMDF_MD_COMPILER_IS_Clang)
86# define ONIXS_B3_UMDF_MD_LIKELY(cond) (__builtin_expect((static_cast<bool>((cond))), true))
87# define ONIXS_B3_UMDF_MD_UNLIKELY(cond) (__builtin_expect((static_cast<bool>((cond))), false))
88#endif
89
90# if defined(ONIXS_B3_UMDF_MD_COMPILER_IS_GNU_or_Clang)
91# define ONIXS_B3_UMDF_MD_UNUSED __attribute__((__unused__))
92# define ONIXS_B3_UMDF_MD_MAY_ALIAS __attribute__((__may_alias__))
93# define ONIXS_B3_UMDF_MD_HOTPATH __attribute__((__hot__))
94# define ONIXS_B3_UMDF_MD_COLDPATH __attribute__((__noinline__,__cold__))
95# define ONIXS_B3_UMDF_MD_NORETURN __attribute__ ((__noreturn__))
96# define ONIXS_B3_UMDF_MD_NODISCARD __attribute__((__warn_unused_result__))
97# define ONIXS_B3_UMDF_MD_PURE
98
99#elif defined(ONIXS_B3_UMDF_MD_COMPILER_IS_MSVC)
100
101# define ONIXS_B3_UMDF_MD_LIKELY(cond) ((cond))
102# define ONIXS_B3_UMDF_MD_UNLIKELY(cond) ((cond))
103# define ONIXS_B3_UMDF_MD_PURE
104# define ONIXS_B3_UMDF_MD_UNUSED
105# define ONIXS_B3_UMDF_MD_MAY_ALIAS
106# define ONIXS_B3_UMDF_MD_HOTPATH
107# define ONIXS_B3_UMDF_MD_COLDPATH
108# define ONIXS_B3_UMDF_MD_NORETURN __declspec(noreturn)
109# define ONIXS_B3_UMDF_MD_NODISCARD _Check_return_
110
111#else
112# error Unsupported compiler
113#endif
114
115
116# define ONIXS_B3_UMDF_MD_CHECK_NOTHROW(equation) ONIXS_B3_UMDF_MD_STATIC_ASSERT(noexcept((equation)))
117# define ONIXS_B3_UMDF_MD_STATIC_ASSERT(X) static_assert(X, #X)
118
119
120#if defined NDEBUG
121# define ONIXS_B3_UMDF_MD_ASSERT(CHECK) void(0)
122#else
123# define ONIXS_B3_UMDF_MD_ASSERT(CHECK) ((CHECK) ? void(0) : []() {assert(!#CHECK);}())
124#endif
125
126
127#else //#if !(defined(ONIXS_DOXYGEN) && ONIXS_DOXYGEN)
128
129#define ONIXS_B3_UMDF_MD_EXPORTED
130#define ONIXS_B3_UMDF_MD_NORETURN
131#define ONIXS_B3_UMDF_MD_NODISCARD
132#define ONIXS_B3_UMDF_MD_HOTPATH
133#define ONIXS_B3_UMDF_MD_COLDPATH
134#define ONIXS_B3_UMDF_MD_PURE
135#define ONIXS_B3_UMDF_MD_UNUSED
136
137#define ONIXS_B3_UMDF_MD_CXX11
138#define ONIXS_B3_UMDF_MD_CXX14
139#define ONIXS_B3_UMDF_MD_CXX17
140#define ONIXS_B3_UMDF_MD_CXX20
141
142#endif