picox  0.1
xgcc.h
1 
14 /*
15  * License: MIT license
16  * Copyright (c) <2015> <MaskedW [maskedw00@gmail.com]>
17  *
18  * Permission is hereby granted, free of charge, to any person
19  * obtaining a copy of this software and associated documentation
20  * files (the "Software"), to deal in the Software without
21  * restriction, including without limitation the rights to use, copy,
22  * modify, merge, publish, distribute, sublicense, and/or sell copies
23  * of the Software, and to permit persons to whom the Software is
24  * furnished to do so, subject to the following conditions:
25  *
26  * The above copyright notice and this permission notice shall be
27  * included in all copies or substantial portions of the Software.
28  *
29  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
30  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
31  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
32  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
33  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
34  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
35  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36  * SOFTWARE.
37  */
38 
39 
40 #ifndef picox_core_detail_compiler_xgcc_h_
41 #define picox_core_detail_compiler_xgcc_h_
42 
43 
44 #ifndef __GNUC__
45  #error This header file required 'GNU C/C++ Compiler'
46 #endif
47 
48 
49 #ifndef __STRICT_ANSI__
50  #define X_HAS_TYPEOF (1)
51  #define X_TYPEOF(x) typeof(x)
52  #define X_HAS_STATEMENT_EXPRESSIONS (1)
53 #endif
54 
55 
56 #define X_HAS_VARIADIC_MACROS (1)
57 #define X_ALWAYS_INLINE static inline __attribute__((__always_inline__))
58 #define X_LIKELY(x) __builtin_expect(!!(x), 1)
59 #define X_UNLIKELY(x) __builtin_expect(!!(x), 0)
60 #define X_MEMORY_BARRIER asm volatile ("" : : : "memory")
61 
62 
63 #if X_GNUC_PREREQ(3, 1)
64  #define X_DEPRECATED __attribute__((__deprecated__))
65 #endif
66 #if X_GNUC_PREREQ(4, 5)
67  #define X_UNREACHABE __builtin_unreachable()
68 #endif
69 
70 #define X_PACKED_PRE_BEGIN
71 #define X_PACKED_POST_BEGIN
72 #define X_PACKED_PRE_END __attribute__((__packed__))
73 #define X_PACKED_POST_END
74 
75 
76 #ifdef X_INTERNAL_DEVMODE
77 #ifndef __cplusplus
78  /* C++のキーワードが使用されていた場合、エラーになるようにする。
79  * マクロやインライン関数内でC++キーワードを使用している場合、振る舞いがやや
80  * こしくなってしまうので、C++キーワードはCでも使用しない方がいい。
81  */
82  #pragma GCC poison new delete class template typename
83  #pragma GCC poison private protected public operator
84  #pragma GCC poison friend mutable using namespace
85  #pragma GCC poison static_cast const_cast reinterpret_cast dynamic_cast
86  #pragma GCC poison explicit export
87  #pragma GCC poison virtual this typeid try catch throw
88  #pragma GCC poison cin cout cerr clog
89 
90  /* C11 features */
91  #pragma GCC poison final nullptr override constexpr
92  #pragma GCC poison alignas alignof auto noexcept static_assert
93  #pragma GCC poison char16_t char32_t
94  #pragma GCC poison thread_local
95 #endif
96 #endif
97 
98 
99 #endif // picox_core_detail_compiler_xgcc_h_