Go to the documentation of this file.
24 #ifndef _QI_MACRO_HPP_
25 # define _QI_MACRO_HPP_
28 #include <boost/predef/compiler.h>
29 #include <boost/config.hpp>
36 #if defined(__GNUC__) && !defined(QI_NO_API_DEPRECATED)
37 # define QI_API_DEPRECATED __attribute__((deprecated))
38 #elif defined(_MSC_VER) && !defined(QI_NO_API_DEPRECATED)
39 # define QI_API_DEPRECATED __declspec(deprecated)
41 # define QI_API_DEPRECATED
50 #if defined(__GNUC__) && !defined(QI_NO_API_DEPRECATED)
51 # define QI_API_DEPRECATED_MSG(msg__) __attribute__((deprecated(#msg__)))
52 #elif defined(_MSC_VER) && !defined(QI_NO_API_DEPRECATED)
53 # define QI_API_DEPRECATED_MSG(msg__) __declspec(deprecated(#msg__))
55 # define QI_API_DEPRECATED_MSG(msg__)
63 # define QI_NORETURN __attribute__((noreturn))
64 #elif defined(_MSC_VER)
65 # define QI_NORETURN __declspec(noreturn)
75 #if defined(__GNUC__) && !defined(__clang__)
76 # define QI_HAS_VARIABLE_LENGTH_ARRAY 1
78 # define QI_HAS_VARIABLE_LENGTH_ARRAY 0
102 #define QI_LIB_API(libname) QI_LIB_API_(BOOST_PP_CAT(libname, _EXPORTS), BOOST_PP_CAT(libname, _STATIC_BUILD))
104 #define QI_LIB_API_(IS_BUILDING_LIB, IS_LIB_STATIC_BUILD) \
105 QI_LIB_API_NORMALIZED(_QI_IS_ONE_OR_EMPTY(BOOST_PP_CAT(_ , IS_BUILDING_LIB)), _QI_IS_ONE_OR_EMPTY(BOOST_PP_CAT(_, IS_LIB_STATIC_BUILD)))
121 #if defined _WIN32 || defined __CYGWIN__
122 # define QI_EXPORT_API __declspec(dllexport)
123 # define QI_IMPORT_API __declspec(dllimport)
124 # define QI_LIB_API_NORMALIZED(exporting, isstatic) BOOST_PP_CAT(BOOST_PP_CAT(_QI_LIB_API_NORMALIZED_, exporting), isstatic)
125 # define _QI_LIB_API_NORMALIZED_00 QI_IMPORT_API
126 # define _QI_LIB_API_NORMALIZED_10 QI_EXPORT_API
127 # define _QI_LIB_API_NORMALIZED_11
128 # define _QI_LIB_API_NORMALIZED_01
130 # define QI_EXPORT_API __attribute__ ((visibility("default")))
131 # define QI_IMPORT_API QI_EXPORT_API
132 # define QI_LIB_API_NORMALIZED(a, b) QI_EXPORT_API
134 # define QI_IMPORT_API
135 # define QI_EXPORT_API
136 # define QI_LIB_API_NORMALIZED(a, b)
142 #if defined(_MSC_VER)
143 #define QI_DO_PRAGMA(x) __pragma(x)
144 #define __ALSTR2__(x) #x
145 #define __ALSTR1__(x) __ALSTR2__(x)
146 #define _ALMSVCLOC_ __FILE__ "("__ALSTR1__(__LINE__)") : "
147 #define QI_MSG_PRAGMA(_msg) QI_DO_PRAGMA(message (_ALMSVCLOC_ _msg))
148 #elif defined(__GNUC__)
149 #define QI_DO_PRAGMA(x) _Pragma (BOOST_PP_STRINGIZE(x))
150 #define QI_MSG_PRAGMA(_msg) QI_DO_PRAGMA(message (_msg))
152 #define QI_DO_PRAGMA(x)
153 #define QI_MSG_PRAGMA(_msg)
163 #if defined(QI_NO_COMPILER_WARNING)
164 # define QI_COMPILER_WARNING(x)
166 # define QI_COMPILER_WARNING(x) QI_MSG_PRAGMA("Warning: " #x)
174 #if !defined(WITH_DEPRECATED) || defined(QI_NO_DEPRECATED_HEADER)
175 # define QI_DEPRECATED_HEADER(x)
177 # define QI_DEPRECATED_HEADER(x) QI_MSG_PRAGMA("\
178 This file includes at least one deprecated or antiquated ALDEBARAN header \
179 which may be removed without further notice in the next version. \
180 Please consult the changelog for details. " #x)
186 template <
typename T>
203 #define QI_DEPRECATE_MACRO(name) \
204 QI_COMPILER_WARNING(name macro is deprecated.)
237 #define QI_DISALLOW_COPY_AND_ASSIGN(type) \
238 QI_DEPRECATE_MACRO(QI_DISALLOW_COPY_AND_ASSIGN) \
239 type(type const &); \
240 void operator=(type const &); \
241 using _qi_not_clonable = int; \
242 template<typename U> friend struct ::qi::IsClonable
249 #if defined(__GNUC__)
250 # define QI_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
252 # define QI_WARN_UNUSED_RESULT
259 #if defined(__GNUC__)
260 # define QI_ATTR_UNUSED __attribute__((unused))
262 # define QI_ATTR_UNUSED
302 #define QI_IGNORE_UNUSED(x) (void)x
309 #define QI_UNIQ_DEF_LEVEL2_(A, B) A ## __uniq__ ## B
310 #define QI_UNIQ_DEF_LEVEL1_(A, B) QI_UNIQ_DEF_LEVEL2_(A, B)
311 #define QI_UNIQ_DEF(A) QI_UNIQ_DEF_LEVEL1_(A, __LINE__)
318 #define QI_NOEXCEPT(cond) BOOST_NOEXCEPT_IF(cond)
325 #define QI_NOEXCEPT_EXPR(expr) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(expr))
333 # define QI_WARNING_PUSH() QI_DO_PRAGMA(warning(push))
334 #elif BOOST_COMP_GNUC
335 # define QI_WARNING_PUSH() QI_DO_PRAGMA(GCC diagnostic push)
336 #elif BOOST_COMP_CLANG
337 # define QI_WARNING_PUSH() QI_DO_PRAGMA(clang diagnostic push)
346 # define QI_WARNING_DISABLE(code, _) \
347 QI_DO_PRAGMA(warning(disable: code))
348 #elif BOOST_COMP_GNUC
349 # define QI_WARNING_DISABLE(_, name) \
350 QI_DO_PRAGMA(GCC diagnostic ignored BOOST_PP_STRINGIZE(BOOST_PP_CAT(-W, name)))
351 #elif BOOST_COMP_CLANG
352 # define QI_WARNING_DISABLE(_, name) \
353 QI_DO_PRAGMA(clang diagnostic ignored BOOST_PP_STRINGIZE(BOOST_PP_CAT(-W, name)))
361 # define QI_WARNING_POP() QI_DO_PRAGMA(warning(pop))
362 #elif BOOST_COMP_GNUC
363 # define QI_WARNING_POP() QI_DO_PRAGMA(GCC diagnostic pop)
364 #elif BOOST_COMP_CLANG
365 # define QI_WARNING_POP() QI_DO_PRAGMA(clang diagnostic pop)
373 #if defined(__has_cpp_attribute) && __cplusplus >= 201703L
374 # if __has_cpp_attribute(fallthrough)
375 # define QI_FALLTHROUGH [[fallthrough]]
378 #ifndef QI_FALLTHROUGH
380 # define QI_FALLTHROUGH __attribute__((fallthrough))
381 # elif defined(__clang__) && __cplusplus >= 201103L && \
382 defined(__has_feature) && defined(__has_warning)
383 # if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
384 # define QI_FALLTHROUGH [[clang::fallthrough]]
388 #ifndef QI_FALLTHROUGH
389 # define QI_FALLTHROUGH ((void)0)
392 #endif // _QI_MACRO_HPP_