libqi-api  2.0.6.8
/home/opennao/work/master/sdk/libqi/qi/macro.hpp
Go to the documentation of this file.
00001 #pragma once
00002 /*
00003  * Copyright (c) 2012 Aldebaran Robotics. All rights reserved.
00004  * Use of this source code is governed by a BSD-style license that can be
00005  * found in the COPYING file.
00006  */
00007 
00012 #ifndef _QI_MACRO_HPP_
00013 #define _QI_MACRO_HPP_
00014 
00015 
00016 
00017 #include <qi/preproc.hpp>
00018 
00019 // Deprecated
00020 #if defined(__GNUC__) && !defined(QI_NO_API_DEPRECATED)
00021 #  define QI_API_DEPRECATED __attribute__((deprecated))
00022 #elif defined(_MSC_VER) && !defined(QI_NO_API_DEPRECATED)
00023 #  define QI_API_DEPRECATED __declspec(deprecated)
00024 #else
00025 #  define QI_API_DEPRECATED
00026 #endif
00027 
00028 
00029 #if defined(__GNUC__)
00030 
00031 #  define QI_NORETURN   __attribute__((noreturn))
00032 #elif defined(_MSC_VER)
00033 
00034 #  define QI_NORETURN   __declspec(noreturn)
00035 #else
00036 #  define QI_NORETURN
00037 #endif
00038 
00039 // Mark compilers supporting variable length array (VLA)
00040 #if defined(__GNUC__) && !defined(__clang__)
00041 #  define QI_HAS_VARIABLE_LENGTH_ARRAY 1
00042 #else
00043 #  define QI_HAS_VARIABLE_LENGTH_ARRAY 0
00044 #endif
00045 
00046 // For shared library
00047 
00048 
00066 #define QI_LIB_API(libname) _QI_LIB_API(BOOST_PP_CAT(libname, _EXPORTS), BOOST_PP_CAT(libname, _STATIC_BUILD))
00067 
00068 #define _QI_LIB_API(IS_BUILDING_LIB, IS_LIB_STATIC_BUILD) \
00069   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)))
00070 
00071 // Each platform must provide a QI_LIB_API_NORMALIZED(isBuilding, isStatic)
00072 #if defined _WIN32 || defined __CYGWIN__
00073 #  define QI_EXPORT_API __declspec(dllexport)
00074 #  define QI_IMPORT_API __declspec(dllimport)
00075 #  define QI_LIB_API_NORMALIZED(exporting, isstatic) BOOST_PP_CAT(BOOST_PP_CAT(_QI_LIB_API_NORMALIZED_, exporting), isstatic)
00076 #  define _QI_LIB_API_NORMALIZED_00 QI_IMPORT_API
00077 #  define _QI_LIB_API_NORMALIZED_10 QI_EXPORT_API
00078 #  define _QI_LIB_API_NORMALIZED_11
00079 #  define _QI_LIB_API_NORMALIZED_01
00080 #elif __GNUC__ >= 4
00081 #  define QI_EXPORT_API __attribute__ ((visibility("default")))
00082 #  define QI_IMPORT_API QI_EXPORT_API
00083 #  define QI_LIB_API_NORMALIZED(a, b) QI_EXPORT_API
00084 #else
00085 #  define QI_IMPORT_API
00086 #  define QI_EXPORT_API
00087 #  define QI_LIB_API_NORMALIZED(a, b)
00088 #endif
00089 
00090 
00092 // Macros adapted from opencv2.2
00093 #if defined(_MSC_VER)
00094   #define QI_DO_PRAGMA(x) __pragma(x)
00095   #define __ALSTR2__(x) #x
00096   #define __ALSTR1__(x) __ALSTR2__(x)
00097   #define _ALMSVCLOC_ __FILE__ "("__ALSTR1__(__LINE__)") : "
00098   #define QI_MSG_PRAGMA(_msg) QI_DO_PRAGMA(message (_ALMSVCLOC_ _msg))
00099 #elif defined(__GNUC__)
00100   #define QI_DO_PRAGMA(x) _Pragma (#x)
00101   #define QI_MSG_PRAGMA(_msg) QI_DO_PRAGMA(message (_msg))
00102 #else
00103   #define QI_DO_PRAGMA(x)
00104   #define QI_MSG_PRAGMA(_msg)
00105 #endif
00106 
00107 
00108 
00109 // Use this macro to generate compiler warnings.
00110 #if defined(QI_NO_COMPILER_WARNING)
00111 # define QI_COMPILER_WARNING(x)
00112 #else
00113 # define QI_COMPILER_WARNING(x) QI_MSG_PRAGMA("Warning: " #x)
00114 #endif
00115 
00116 // Deprecate a header, add a message to explain what user should do
00117 #if !defined(WITH_DEPRECATED) || defined(QI_NO_DEPRECATED_HEADER)
00118 # define QI_DEPRECATED_HEADER(x)
00119 #else
00120 # define QI_DEPRECATED_HEADER(x) QI_MSG_PRAGMA("\
00121 This file includes at least one deprecated or antiquated ALDEBARAN header \
00122 which may be removed without further notice in the next version. \
00123 Please consult the changelog for details. " #x)
00124 #endif
00125 
00126 
00127 #ifdef __cplusplus
00128 namespace qi {
00129   template <typename T>
00130   struct IsClonable;
00131 };
00132 #endif
00133 
00134 #define QI_DEPRECATE_MACRO(name)                \
00135   QI_COMPILER_WARNING(name macro is deprecated.)
00136 
00137 // This macro is deprecated, use boost::noncopyable instead
00138 #define QI_DISALLOW_COPY_AND_ASSIGN(type)       \
00139   QI_DEPRECATE_MACRO(QI_DISALLOW_COPY_AND_ASSIGN) \
00140   type(type const &);                           \
00141   void operator=(type const &);               \
00142   typedef int _qi_not_clonable;                 \
00143   template<typename U> friend struct ::qi::IsClonable
00144 
00145 
00146 #if defined(__GNUC__)
00147 # define QI_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
00148 #else
00149 # define QI_WARN_UNUSED_RESULT
00150 #endif
00151 
00152 #if defined(__GNUC__)
00153 # define QI_ATTR_UNUSED __attribute__((unused))
00154 #else
00155 # define QI_ATTR_UNUSED
00156 #endif
00157 
00158 #define QI_UNUSED(x)
00159 
00160 // A macro to append the line number of the parent macro usage, to define a
00161 // function in or a variable and avoid name collision.
00162 #define _QI_UNIQ_DEF_LEVEL2(A, B) A ## __uniq__ ## B
00163 #define _QI_UNIQ_DEF_LEVEL1(A, B) _QI_UNIQ_DEF_LEVEL2(A, B)
00164 #define QI_UNIQ_DEF(A) _QI_UNIQ_DEF_LEVEL1(A, __LINE__)
00165 
00166 
00167 #endif  // _QI_MACRO_HPP_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines