- Aldebaran documentation |
- C++ Libraries |
- index

libqi-api 2.8.7.4

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
macro.hpp
Go to the documentation of this file.
1 #pragma once
2 /*
3 * Copyright (c) 2012 Aldebaran Robotics. All rights reserved.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the COPYING file.
6 */
7
24 #ifndef _QI_MACRO_HPP_
25 # define _QI_MACRO_HPP_
26
27 # include <qi/preproc.hpp>
28 #include <boost/predef/compiler.h>
29 #include <boost/config.hpp>
30
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)
40 #else
41 # define QI_API_DEPRECATED
42 #endif
43
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__))
54 #else
55 # define QI_API_DEPRECATED_MSG(msg__)
56 #endif
57
62 #if defined(__GNUC__)
63 # define QI_NORETURN __attribute__((noreturn))
64 #elif defined(_MSC_VER)
65 # define QI_NORETURN __declspec(noreturn)
67 #else
68 # define QI_NORETURN
69 #endif
70
75 #if defined(__GNUC__) && !defined(__clang__)
76 # define QI_HAS_VARIABLE_LENGTH_ARRAY 1
77 #else
78 # define QI_HAS_VARIABLE_LENGTH_ARRAY 0
79 #endif
80
81 // For shared library
82
83
102 #define QI_LIB_API(libname) QI_LIB_API_(BOOST_PP_CAT(libname, _EXPORTS), BOOST_PP_CAT(libname, _STATIC_BUILD))
103
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)))
106
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
129 #elif __GNUC__ >= 4
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
133 #else
134 # define QI_IMPORT_API
135 # define QI_EXPORT_API
136 # define QI_LIB_API_NORMALIZED(a, b)
137 #endif
138
139
141 // Macros adapted from opencv2.2
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))
151 #else
152 #define QI_DO_PRAGMA(x)
153 #define QI_MSG_PRAGMA(_msg)
154 #endif
155
157
163 #if defined(QI_NO_COMPILER_WARNING)
164 # define QI_COMPILER_WARNING(x)
165 #else
166 # define QI_COMPILER_WARNING(x) QI_MSG_PRAGMA("Warning: " #x)
167 #endif
168
174 #if !defined(WITH_DEPRECATED) || defined(QI_NO_DEPRECATED_HEADER)
175 # define QI_DEPRECATED_HEADER(x)
176 #else
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)
181 #endif
182
183
184 #ifdef __cplusplus
185 namespace qi {
186 template <typename T>
187 struct IsClonable;
188 };
189 #endif
190
203 #define QI_DEPRECATE_MACRO(name) \
204 QI_COMPILER_WARNING(name macro is deprecated.)
205
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
243
244
249 #if defined(__GNUC__)
250 # define QI_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
251 #else
252 # define QI_WARN_UNUSED_RESULT
253 #endif
254
259 #if defined(__GNUC__)
260 # define QI_ATTR_UNUSED __attribute__((unused))
261 #else
262 # define QI_ATTR_UNUSED
263 #endif
264
279 #define QI_UNUSED(x)
280
302 #define QI_IGNORE_UNUSED(x) (void)x
303
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__)
312
318 #define QI_NOEXCEPT(cond) BOOST_NOEXCEPT_IF(cond)
319
325 #define QI_NOEXCEPT_EXPR(expr) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(expr))
326
327
332 #if BOOST_COMP_MSVC
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)
338 #endif
339
345 #if BOOST_COMP_MSVC
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)))
354 #endif
355
360 #if BOOST_COMP_MSVC
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)
366 #endif
367
373 #if defined(__has_cpp_attribute) && __cplusplus >= 201703L
374 # if __has_cpp_attribute(fallthrough)
375 # define QI_FALLTHROUGH [[fallthrough]]
376 # endif
377 #endif
378 #ifndef QI_FALLTHROUGH
379 # if __GNUC__ >= 7
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]]
385 # endif
386 # endif
387 #endif
388 #ifndef QI_FALLTHROUGH
389 # define QI_FALLTHROUGH ((void)0)
390 #endif
391
392 #endif // _QI_MACRO_HPP_
preproc.hpp