libqi  1.14
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
macro.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 Aldebaran Robotics. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the COPYING file.
5  */
6 
11 #pragma once
12 #ifndef _LIBQI_QI_API_HPP_
13 #define _LIBQI_QI_API_HPP_
14 
15 // Deprecated
16 #if defined(__GNUC__) && defined(WITH_DEPRECATED) && !defined(QI_NO_API_DEPRECATED)
17 # define QI_API_DEPRECATED __attribute__((deprecated))
18 #elif defined(_MSC_VER) && defined(WITH_DEPRECATED) && !defined(QI_NO_API_DEPRECATED)
19 # define QI_API_DEPRECATED __declspec(deprecated)
20 #else
21 # define QI_API_DEPRECATED
22 #endif
23 
24 // For shared library
25 #if defined _WIN32 || defined __CYGWIN__
26 # define QI_EXPORT_API __declspec(dllexport)
27 # if defined _WINDLL
28 # define QI_IMPORT_API __declspec(dllimport)
29 # else
30 # define QI_IMPORT_API
31 # endif
32 #elif __GNUC__ >= 4
33 # define QI_EXPORT_API __attribute__ ((visibility("default")))
34 # define QI_IMPORT_API __attribute__ ((visibility("default")))
35 #else
36 # define QI_EXPORT_API
37 # define QI_IMPORT_API
38 #endif
39 
40 
42 // Macros adapted from opencv2.2
43 #if defined(_MSC_VER)
44  #define QI_DO_PRAGMA(x) __pragma(x)
45  #define __ALSTR2__(x) #x
46  #define __ALSTR1__(x) __ALSTR2__(x)
47  #define _ALMSVCLOC_ __FILE__ "("__ALSTR1__(__LINE__)") : "
48  #define QI_MSG_PRAGMA(_msg) QI_DO_PRAGMA(message (_ALMSVCLOC_ _msg))
49 #elif defined(__GNUC__)
50  #define QI_DO_PRAGMA(x) _Pragma (#x)
51  #define QI_MSG_PRAGMA(_msg) QI_DO_PRAGMA(message (_msg))
52 #else
53  #define QI_DO_PRAGMA(x)
54  #define QI_MSG_PRAGMA(_msg)
55 #endif
56 
57 
58 
59 // Use this macro to generate compiler warnings.
60 #if !defined(WITH_DEPRECATED) || defined(QI_NO_COMPILER_WARNING)
61 # define QI_COMPILER_WARNING(x)
62 #else
63 # define QI_COMPILER_WARNING(x) QI_MSG_PRAGMA("Warning: " #x)
64 #endif
65 
66 // Deprecate a header, add a message to explain what user should do
67 #if !defined(WITH_DEPRECATED) || defined(QI_NO_DEPRECATED_HEADER)
68 # define QI_DEPRECATED_HEADER(x)
69 #else
70 # define QI_DEPRECATED_HEADER(x) QI_MSG_PRAGMA("\
71 This file includes at least one deprecated or antiquated ALDEBARAN header \
72 which may be removed without further notice in the next version. \
73 Please consult the changelog for details. " #x)
74 #endif
75 
76 
77 // A macro to disallow copy constructor and operator=
78 #define QI_DISALLOW_COPY_AND_ASSIGN(type) \
79  type(type const &); \
80  void operator=(type const &)
81 
82 #if defined(__GNUC__)
83 # define QI_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
84 #else
85 # define QI_WARN_UNUSED_RESULT
86 #endif
87 
88 #define QI_UNUSED(x)
89 
90 #endif // _LIBQI_QI_API_HPP_
91