libqi  1.14.5
qi/macro.hpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2012 Aldebaran Robotics. All rights reserved.
00003  * Use of this source code is governed by a BSD-style license that can be
00004  * found in the COPYING file.
00005  */
00006 
00011 #pragma once
00012 #ifndef _LIBQI_QI_API_HPP_
00013 #define _LIBQI_QI_API_HPP_
00014 
00015 // Deprecated
00016 #if defined(__GNUC__) && defined(WITH_DEPRECATED) && !defined(QI_NO_API_DEPRECATED)
00017 #  define QI_API_DEPRECATED __attribute__((deprecated))
00018 #elif defined(_MSC_VER) && defined(WITH_DEPRECATED) && !defined(QI_NO_API_DEPRECATED)
00019 #  define QI_API_DEPRECATED __declspec(deprecated)
00020 #else
00021 #  define QI_API_DEPRECATED
00022 #endif
00023 
00024 // For shared library
00025 #if defined _WIN32 || defined __CYGWIN__
00026 #  define QI_EXPORT_API __declspec(dllexport)
00027 #  if defined _WINDLL
00028 #    define QI_IMPORT_API __declspec(dllimport)
00029 #  else
00030 #    define QI_IMPORT_API
00031 #  endif
00032 #elif __GNUC__ >= 4
00033 #  define QI_EXPORT_API __attribute__ ((visibility("default")))
00034 #  define QI_IMPORT_API __attribute__ ((visibility("default")))
00035 #else
00036 #  define QI_EXPORT_API
00037 #  define QI_IMPORT_API
00038 #endif
00039 
00040 
00042 // Macros adapted from opencv2.2
00043 #if defined(_MSC_VER)
00044   #define QI_DO_PRAGMA(x) __pragma(x)
00045   #define __ALSTR2__(x) #x
00046   #define __ALSTR1__(x) __ALSTR2__(x)
00047   #define _ALMSVCLOC_ __FILE__ "("__ALSTR1__(__LINE__)") : "
00048   #define QI_MSG_PRAGMA(_msg) QI_DO_PRAGMA(message (_ALMSVCLOC_ _msg))
00049 #elif defined(__GNUC__)
00050   #define QI_DO_PRAGMA(x) _Pragma (#x)
00051   #define QI_MSG_PRAGMA(_msg) QI_DO_PRAGMA(message (_msg))
00052 #else
00053   #define QI_DO_PRAGMA(x)
00054   #define QI_MSG_PRAGMA(_msg)
00055 #endif
00056 
00057 
00058 
00059 // Use this macro to generate compiler warnings.
00060 #if !defined(WITH_DEPRECATED) || defined(QI_NO_COMPILER_WARNING)
00061 # define QI_COMPILER_WARNING(x)
00062 #else
00063 # define QI_COMPILER_WARNING(x) QI_MSG_PRAGMA("Warning: " #x)
00064 #endif
00065 
00066 // Deprecate a header, add a message to explain what user should do
00067 #if !defined(WITH_DEPRECATED) || defined(QI_NO_DEPRECATED_HEADER)
00068 # define QI_DEPRECATED_HEADER(x)
00069 #else
00070 # define QI_DEPRECATED_HEADER(x) QI_MSG_PRAGMA("\
00071 This file includes at least one deprecated or antiquated ALDEBARAN header \
00072 which may be removed without further notice in the next version. \
00073 Please consult the changelog for details. " #x)
00074 #endif
00075 
00076 
00077 // A macro to disallow copy constructor and operator=
00078 #define QI_DISALLOW_COPY_AND_ASSIGN(type)       \
00079   type(type const &);                           \
00080   void operator=(type const &)
00081 
00082 #if defined(__GNUC__)
00083 # define QI_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
00084 #else
00085 # define QI_WARN_UNUSED_RESULT
00086 #endif
00087 
00088 #define QI_UNUSED(x)
00089 
00090 #endif  // _LIBQI_QI_API_HPP_
00091 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines