libcopp  2.2.0
explicit_declare.h
Go to the documentation of this file.
1 
13 #ifndef STD_EXPLICIT_DECLARE_H
14 #define STD_EXPLICIT_DECLARE_H
15 
16 #pragma once
17 
18 // ============================================================
19 // 公共包含部分
20 // C++0x/11/14/17 显示申明
21 // ============================================================
22 
23 #ifndef PARAM_IN
24 # if defined(_MSC_VER) && _MSC_VER >= 1700 // vs 2012 or higher
25 # define PARAM_IN _In_
26 # else
27 # define PARAM_IN
28 # endif
29 #endif
30 
31 #ifndef PARAM_OUT
32 # if defined(_MSC_VER) && _MSC_VER >= 1700 // vs 2012 or higher
33 # define PARAM_OUT _Out_
34 # else
35 # define PARAM_OUT
36 # endif
37 #endif
38 
39 #ifndef PARAM_INOUT
40 # if defined(_MSC_VER) && _MSC_VER >= 1700 // vs 2012 or higher
41 # define PARAM_INOUT _Inout_
42 # else
43 # define PARAM_INOUT
44 # endif
45 #endif
46 
58 #if defined(__cplusplus) && __cplusplus >= 201402L
59 # define EXPLICIT_DEPRECATED_ATTR [[deprecated]]
60 #elif defined(__clang__)
61 # define EXPLICIT_DEPRECATED_ATTR __attribute__((deprecated))
62 #elif defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
63 # define EXPLICIT_DEPRECATED_ATTR __attribute__((deprecated))
64 #elif defined(_MSC_VER) && _MSC_VER >= 1400 // vs 2005 or higher
65 # if _MSC_VER >= 1910 && defined(_MSVC_LANG) && _MSVC_LANG >= 201703L
66 # define EXPLICIT_DEPRECATED_ATTR [[deprecated]]
67 # else
68 # define EXPLICIT_DEPRECATED_ATTR __declspec(deprecated)
69 # endif
70 #else
71 # define EXPLICIT_DEPRECATED_ATTR
72 #endif
73 
74 #if defined(__cplusplus) && __cplusplus >= 201402L
75 # define EXPLICIT_DEPRECATED_MSG(msg) [[deprecated(msg)]]
76 #elif defined(__clang__)
77 # define EXPLICIT_DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
78 #elif defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
79 # define EXPLICIT_DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
80 #elif defined(_MSC_VER) && _MSC_VER >= 1400 // vs 2005 or higher
81 # if _MSC_VER >= 1910 && defined(_MSVC_LANG) && _MSVC_LANG >= 201703L
82 # define EXPLICIT_DEPRECATED_MSG(msg) [[deprecated(msg)]]
83 # else
84 # define EXPLICIT_DEPRECATED_MSG(msg) __declspec(deprecated(msg))
85 # endif
86 #else
87 # define EXPLICIT_DEPRECATED_MSG(msg)
88 #endif
89 
97 #if defined(__cplusplus) && __cplusplus >= 201703L
98 # define EXPLICIT_NODISCARD_ATTR [[nodiscard]]
99 #elif defined(__clang__)
100 # define EXPLICIT_NODISCARD_ATTR __attribute__((warn_unused_result))
101 #elif defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
102 # define EXPLICIT_NODISCARD_ATTR __attribute__((warn_unused_result))
103 #elif defined(_MSC_VER) && _MSC_VER >= 1700 // vs 2012 or higher
104 # if _MSC_VER >= 1910 && defined(_MSVC_LANG) && _MSVC_LANG >= 201703L
105 # define EXPLICIT_NODISCARD_ATTR [[nodiscard]]
106 # else
107 # define EXPLICIT_NODISCARD_ATTR _Check_return_
108 # endif
109 #else
110 # define EXPLICIT_NODISCARD_ATTR
111 #endif
112 
120 #if defined(__cplusplus) && __cplusplus >= 201703L
121 # define EXPLICIT_UNUSED_ATTR [[maybe_unused]]
122 #elif defined(__clang__)
123 # define EXPLICIT_UNUSED_ATTR __attribute__((unused))
124 #elif defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
125 # define EXPLICIT_UNUSED_ATTR __attribute__((unused))
126 #elif defined(_MSC_VER) && _MSC_VER >= 1700 // vs 2012 or higher
127 # if _MSC_VER >= 1910 && defined(_MSVC_LANG) && _MSVC_LANG >= 201703L
128 # define EXPLICIT_UNUSED_ATTR [[maybe_unused]]
129 # else
130 # define EXPLICIT_UNUSED_ATTR
131 # endif
132 #else
133 # define EXPLICIT_UNUSED_ATTR
134 #endif
135 
144 #if defined(__cplusplus) && __cplusplus >= 201703L
145 # define EXPLICIT_FALLTHROUGH [[fallthrough]];
146 #elif defined(__clang__) && ((__clang_major__ * 100) + __clang_minor__) >= 309
147 # if defined(__apple_build_version__)
148 # define EXPLICIT_FALLTHROUGH
149 # elif defined(__has_warning) && __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
150 # define EXPLICIT_FALLTHROUGH [[clang::fallthrough]];
151 # else
152 # define EXPLICIT_FALLTHROUGH
153 # endif
154 #elif defined(__GNUC__) && (__GNUC__ >= 7)
155 # define EXPLICIT_FALLTHROUGH [[gnu::fallthrough]];
156 #elif defined(_MSC_VER) && _MSC_VER >= 1700 // vs 2012 or higher
157 # if _MSC_VER >= 1910 && defined(_MSVC_LANG) && _MSVC_LANG >= 201703L
158 # define EXPLICIT_FALLTHROUGH [[fallthrough]];
159 # else
160 # define EXPLICIT_FALLTHROUGH
161 # endif
162 #else
163 # define EXPLICIT_FALLTHROUGH
164 #endif
165 
166 #endif