pinocchio
2.4.0-dirty
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
macros.hpp
1
//
2
// Copyright (c) 2017-2019 CNRS INRIA
3
//
4
5
#ifndef __pinocchio_macros_hpp__
6
#define __pinocchio_macros_hpp__
7
8
#if __cplusplus >= 201103L
9
#define PINOCCHIO_WITH_CXX11_SUPPORT
10
#endif
11
12
#if __cplusplus >= 201403L
13
#define PINOCCHIO_WITH_CXX14_SUPPORT
14
#endif
15
16
#if __cplusplus >= 201703L
17
#define PINOCCHIO_WITH_CXX17_SUPPORT
18
#endif
19
20
#define PINOCCHIO_STRING_LITERAL(string) #string
21
22
// For more details, visit https://stackoverflow.com/questions/171435/portability-of-warning-preprocessor-directive
23
#if defined(__GNUC__) || defined(__clang__)
24
#define PINOCCHIO_PRAGMA(x) _Pragma(#x)
25
#define PINOCCHIO_PRAGMA_MESSAGE(the_message) PINOCCHIO_PRAGMA(GCC message #the_message)
26
#define PINOCCHIO_PRAGMA_WARNING(the_message) PINOCCHIO_PRAGMA(GCC warning #the_message)
27
#define PINOCCHIO_PRAGMA_DEPRECATED(the_message) PINOCCHIO_PRAGMA_WARNING(Deprecated: #the_message)
28
#define PINOCCHIO_PRAGMA_DEPRECATED_HEADER(old_header,new_header) \
29
PINOCCHIO_PRAGMA_WARNING(Deprecated header file: #old_header has been replaced by #new_header.\n Please use #new_header instead of #old_header.)
30
#endif
31
32
// This macro can be used to prevent from macro expansion, similarly to EIGEN_NOT_A_MACRO
33
#define PINOCCHIO_NOT_A_MACRO
34
35
namespace
pinocchio
36
{
37
namespace
helper
38
{
39
template
<
typename
T>
struct
argument_type
;
40
template
<
typename
T,
typename
U>
struct
argument_type
<T(U)> {
typedef
U type; };
41
}
42
}
43
45
#define PINOCCHIO_MACRO_EMPTY_ARG
46
48
#define PINOCCHIO_UNUSED_VARIABLE(var) (void)(var)
49
51
#define PINOCCHIO_ASSERT_MATRIX_SPECIFIC_SIZE(type,M,nrows,ncols) \
52
EIGEN_STATIC_ASSERT( (type::RowsAtCompileTime == Eigen::Dynamic || type::RowsAtCompileTime == nrows) \
53
&& (type::ColsAtCompileTime == Eigen::Dynamic || type::ColsAtCompileTime == ncols),\
54
THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE); \
55
assert(M.rows()==nrows && M.cols()==ncols);
56
60
#define PINOCCHIO_STATIC_ASSERT(condition,msg) \
61
{ int msg[(condition) ? 1 : -1];
/*avoid unused-variable warning*/
(void) msg; }
62
63
namespace
pinocchio
64
{
65
namespace
helper
66
{
67
template
<
typename
D,
template
<
typename
>
class
TypeAccess>
68
struct
handle_return_type_without_typename
69
{
70
typedef
typename
TypeAccess< typename argument_type<void(D)>::type >::type type;
71
};
72
}
73
}
74
75
// Handle explicitely the GCC borring warning: 'anonymous variadic macros were introduced in C++11'
76
#include <exception>
77
#include <stdexcept>
78
79
#if defined(__GNUC__)
80
#pragma GCC system_header
81
#endif
82
83
#if defined(__GNUC__) || defined(__clang__)
84
#pragma GCC diagnostic push
85
#pragma GCC diagnostic ignored "-Wvariadic-macros"
86
#endif
87
89
#if !defined(PINOCCHIO_NO_THROW)
90
#define PINOCCHIO_THROW(condition,exception_type,message) \
91
if (!(condition)) { throw exception_type(PINOCCHIO_STRING_LITERAL(message)); }
92
#else
93
#define PINOCCHIO_THROW(condition,exception_type,message)
94
#endif
95
96
#define _PINOCCHIO_GET_OVERRIDE_FOR_CHECK_INPUT_ARGUMENT(_1, _2, MACRO_NAME, ...) MACRO_NAME
97
98
#define _PINOCCHIO_CHECK_INPUT_ARGUMENT_2(condition, message) \
99
PINOCCHIO_THROW(condition,std::invalid_argument,PINOCCHIO_STRING_LITERAL(message))
100
101
#define _PINOCCHIO_CHECK_INPUT_ARGUMENT_1(condition) \
102
_PINOCCHIO_CHECK_INPUT_ARGUMENT_2(condition,\
103
"The following check on the input argument has failed: "#condition)
104
105
#define _PINOCCHIO_CHECK_INPUT_ARGUMENT_0
106
108
#define PINOCCHIO_CHECK_INPUT_ARGUMENT(...) \
109
_PINOCCHIO_GET_OVERRIDE_FOR_CHECK_INPUT_ARGUMENT(__VA_ARGS__,_PINOCCHIO_CHECK_INPUT_ARGUMENT_2,\
110
_PINOCCHIO_CHECK_INPUT_ARGUMENT_1,_PINOCCHIO_CHECK_INPUT_ARGUMENT_0)(__VA_ARGS__)
111
112
#if defined(__GNUC__) || defined(__clang__)
113
#pragma GCC diagnostic pop
114
#endif
115
116
#endif // ifndef __pinocchio_macros_hpp__
pinocchio::helper::handle_return_type_without_typename
Definition:
macros.hpp:68
pinocchio::helper::argument_type
Definition:
macros.hpp:39
pinocchio
Main pinocchio namespace.
Definition:
treeview.dox:24
src
macros.hpp
Generated by
1.8.13