IRC_SERVER
By @hyunjunk (hyunjun2372@gmail.com)
Loading...
Searching...
No Matches
AttributeDefines.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#if !defined(__GNUC__) && !defined(_MSC_VER)
4
#error "This compiler is not supported"
5
#endif
6
7
#if defined(__GNUC__)
8
#define NODISCARD __attribute__((warn_unused_result))
9
#elif defined(_MSC_VER)
10
// [[nodiscard]] Visual Studio 2017 version 15.3 and later: (Available with /std:c++17 and later.)
11
#if _MSC_VER >= 1911
12
#define NODISCARD [[nodiscard]]
13
#else
14
#define NODISCARD
15
#endif
16
#else
17
#define NODISCARD
18
#endif
19
20
#if defined(__GNUC__)
21
#define UNUSED __attribute__((unused))
22
#elif defined(_MSC_VER)
23
// [[[maybe_unused]] enable Visual Studio 2017 version 15.3 and later: (Available with /std:c++17 and later.)
24
#if _MSC_VER >= 1911
25
#define UNUSED [[maybe_unused]]
26
#else
27
#define UNUSED
28
#endif
29
#else
30
#define UNUSED
31
#endif
32
33
#if defined(__GNUC__)
34
#define LIKELY(x) __builtin_expect(!!(x), 1)
35
#define UNLIKELY(x) __builtin_expect(!!(x), 0)
36
#elif defined(_MSC_VER)
37
// [[likely]] enable Visual Studio 2019 version 16.6 and later: (Available with /std:c++20 and later.)
38
#if _MSC_VER >= 1926
39
#define LIKELY(x) [[likely]] (x)
40
#define UNLIKELY(x) [[unlikely]] (x)
41
#else
42
#define LIKELY(x) (x)
43
#define UNLIKELY(x) (x)
44
#endif
45
#else
46
#define LIKELY(x) (x)
47
#define UNLIKELY(x) (x)
48
#endif
49
50
#if defined(__GNUC__)
51
#define FORCEINLINE __attribute__((always_inline)) inline
52
#elif defined(_MSC_VER)
53
#define FORCEINLINE __forceinline
54
#else
55
#define FORCEINLINE inline
56
#endif
57
58
#if defined(__GNUC__)
59
#define NOINLINE __attribute__((noinline))
60
#elif defined(_MSC_VER)
61
#define NOINLINE __declspec(noinline)
62
#else
63
#define NOINLINE
64
#endif
65
66
#if defined(__GNUC__)
67
#define ALIGNAS(x) __attribute__((aligned(x)))
68
#elif defined(_MSC_VER)
69
#define ALIGNAS(x) __declspec(align(x))
70
#else
71
#error "This compiler is not supported"
72
#endif
73
74
#if defined(__GNUC__)
75
#define ALIGNOF(x) __alignof__(x)
76
#elif defined(_MSC_VER)
77
#define ALIGNOF(x) __alignof(x)
78
#else
79
#error "This compiler is not supported"
80
#endif
81
82
#if defined(__GNUC__)
83
#define NORETURN __attribute__((noreturn))
84
#elif defined(_MSC_VER)
85
#define NORETURN __declspec(noreturn)
86
#else
87
#define NORETURN
88
#endif
Source
Core
AttributeDefines.hpp
Generated by
1.12.0