include
pinocchio
include/pinocchio/macros.hpp
Go to the documentation of this file.
1
//
2
// Copyright (c) 2017-2020 CNRS INRIA
3
//
4
5
#ifndef __pinocchio_macros_hpp__
6
#define __pinocchio_macros_hpp__
7
8
// On Windows, __cplusplus is not necessarily set to the C++ version being used.
9
// See https://docs.microsoft.com/fr-fr/cpp/build/reference/zc-cplusplus?view=vs-2019 for further information.
10
11
#if (__cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703))
12
#define PINOCCHIO_WITH_CXX17_SUPPORT
13
#endif
14
15
#if (__cplusplus >= 201402L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201403))
16
#define PINOCCHIO_WITH_CXX14_SUPPORT
17
#endif
18
19
#if (__cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600))
20
#define PINOCCHIO_WITH_CXX11_SUPPORT
21
#endif
22
23
#define PINOCCHIO_STRING_LITERAL(string) #string
24
25
// For more details, visit https://stackoverflow.com/questions/171435/portability-of-warning-preprocessor-directive
26
#if defined(__GNUC__) || defined(__clang__)
27
#define PINOCCHIO_PRAGMA(x) _Pragma(#x)
28
#define PINOCCHIO_PRAGMA_MESSAGE(the_message) PINOCCHIO_PRAGMA(GCC message #the_message)
29
#define PINOCCHIO_PRAGMA_WARNING(the_message) PINOCCHIO_PRAGMA(GCC warning #the_message)
30
#define PINOCCHIO_PRAGMA_DEPRECATED(the_message) PINOCCHIO_PRAGMA_WARNING(Deprecated: #the_message)
31
#define PINOCCHIO_PRAGMA_DEPRECATED_HEADER(old_header,new_header) \
32
PINOCCHIO_PRAGMA_WARNING(Deprecated header file: #old_header has been replaced by #new_header.\n Please use #new_header instead of #old_header.)
33
#endif
34
35
// This macro can be used to prevent from macro expansion, similarly to EIGEN_NOT_A_MACRO
36
#define PINOCCHIO_NOT_A_MACRO
37
38
namespace
pinocchio
39
{
40
namespace
helper
41
{
42
template
<
typename
T>
struct
argument_type
;
43
template
<
typename
T,
typename
U>
struct
argument_type
<
T
(
U
)> {
typedef
U
type
; };
44
}
45
}
46
48
#define PINOCCHIO_MACRO_EMPTY_ARG
49
51
#define PINOCCHIO_UNUSED_VARIABLE(var) (void)(var)
52
54
#define PINOCCHIO_ASSERT_MATRIX_SPECIFIC_SIZE(type,M,nrows,ncols) \
55
EIGEN_STATIC_ASSERT( (type::RowsAtCompileTime == Eigen::Dynamic || type::RowsAtCompileTime == nrows) \
56
&& (type::ColsAtCompileTime == Eigen::Dynamic || type::ColsAtCompileTime == ncols),\
57
THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE); \
58
assert(M.rows()==nrows && M.cols()==ncols);
59
63
#define PINOCCHIO_STATIC_ASSERT(condition,msg) \
64
{ int msg[(condition) ? 1 : -1];
/*avoid unused-variable warning*/
(void) msg; }
65
66
namespace
pinocchio
67
{
68
namespace
helper
69
{
70
template
<
typename
D,
template
<
typename
>
class
TypeAccess>
71
struct
handle_return_type_without_typename
72
{
73
typedef
typename
TypeAccess<
typename
argument_type
<void(D)>
::type
>
::type
type
;
74
};
75
}
76
}
77
79
#if defined(__GNUC__) || defined(__clang__)
80
# define PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
81
# define PINOCCHIO_COMPILER_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
82
# define PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_DEPRECECATED_DECLARATIONS _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
83
# if defined(__clang__)
84
# define PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
85
# else
86
# define PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED _Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
87
# endif
88
#elif defined (WIN32)
89
# define PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH _Pragma("warning(push)")
90
# define PINOCCHIO_COMPILER_DIAGNOSTIC_POP _Pragma("warning(pop)")
91
# define PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_DEPRECECATED_DECLARATIONS _Pragma("warning(disable : 4996)")
92
# define PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
93
#else
94
# define PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
95
# define PINOCCHIO_COMPILER_DIAGNOSTIC_POP
96
# define PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_DEPRECECATED_DECLARATIONS
97
# define PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
98
#endif // __GNUC__
99
100
// Handle explicitely the GCC boring warning: 'anonymous variadic macros were introduced in C++11'
101
#include <exception>
102
#include <stdexcept>
103
104
#if defined(__GNUC__)
105
#pragma GCC system_header
106
#endif
107
108
#if defined(__GNUC__) || defined(__clang__)
109
#pragma GCC diagnostic push
110
#pragma GCC diagnostic ignored "-Wvariadic-macros"
111
#endif
112
114
#if !defined(PINOCCHIO_NO_THROW)
115
#define PINOCCHIO_THROW(condition,exception_type,message) \
116
if (!(condition)) { throw exception_type(message); }
117
#else
118
#define PINOCCHIO_THROW(condition,exception_type,message)
119
#endif
120
121
#define _PINOCCHIO_EXPAND(x) x
122
#define _PINOCCHIO_GET_OVERRIDE_FOR_CHECK_INPUT_ARGUMENT(_1, _2, MACRO_NAME, ...) MACRO_NAME
123
124
#define _PINOCCHIO_CHECK_INPUT_ARGUMENT_2(condition, message) \
125
PINOCCHIO_THROW(condition,std::invalid_argument,message)
126
127
#define _PINOCCHIO_CHECK_INPUT_ARGUMENT_1(condition) \
128
_PINOCCHIO_CHECK_INPUT_ARGUMENT_2(condition,\
129
"The following check on the input argument has failed: "#condition)
130
131
#define _PINOCCHIO_CHECK_INPUT_ARGUMENT_0
132
134
#define PINOCCHIO_CHECK_INPUT_ARGUMENT(...) \
135
_PINOCCHIO_EXPAND(_PINOCCHIO_EXPAND(_PINOCCHIO_GET_OVERRIDE_FOR_CHECK_INPUT_ARGUMENT(__VA_ARGS__,_PINOCCHIO_CHECK_INPUT_ARGUMENT_2,\
136
_PINOCCHIO_CHECK_INPUT_ARGUMENT_1,_PINOCCHIO_CHECK_INPUT_ARGUMENT_0))(__VA_ARGS__))
137
138
#define _PINOCCHIO_GET_OVERRIDE_FOR_CHECK_ARGUMENT_SIZE(_1, _2, _3, MACRO_NAME, ...) MACRO_NAME
139
140
#define _PINOCCHIO_CHECK_ARGUMENT_SIZE_3(size, expected_size, message) \
141
if (size != expected_size) { \
142
std::ostringstream oss; \
143
oss << "wrong argument size: expected " << expected_size << ", got " << size << std::endl; \
144
oss << "hint: " << message << std::endl; \
145
PINOCCHIO_THROW(false, std::invalid_argument, oss.str()); \
146
}
147
148
#define _PINOCCHIO_CHECK_ARGUMENT_SIZE_2(size, expected_size) \
149
_PINOCCHIO_CHECK_ARGUMENT_SIZE_3(size, expected_size, PINOCCHIO_STRING_LITERAL(size) " is different from " PINOCCHIO_STRING_LITERAL(expected_size))
150
151
#define _PINOCCHIO_CHECK_ARGUMENT_SIZE_1
152
154
#define PINOCCHIO_CHECK_ARGUMENT_SIZE(...) \
155
_PINOCCHIO_EXPAND(_PINOCCHIO_EXPAND(_PINOCCHIO_GET_OVERRIDE_FOR_CHECK_ARGUMENT_SIZE(__VA_ARGS__,_PINOCCHIO_CHECK_ARGUMENT_SIZE_3, \
156
_PINOCCHIO_CHECK_ARGUMENT_SIZE_2, _PINOCCHIO_CHECK_ARGUMENT_SIZE_1))(__VA_ARGS__))
157
158
#if defined(__GNUC__) || defined(__clang__)
159
#pragma GCC diagnostic pop
160
#endif
161
162
#endif // ifndef __pinocchio_macros_hpp__
simulation-pendulum.T
int T
Definition:
simulation-pendulum.py:113
pinocchio::helper::handle_return_type_without_typename::type
TypeAccess< typename argument_type< void(D)>::type >::type type
Definition:
include/pinocchio/macros.hpp:73
pinocchio::helper::argument_type< T(U)>::type
U type
Definition:
include/pinocchio/macros.hpp:43
pinocchio::helper::handle_return_type_without_typename
Definition:
include/pinocchio/macros.hpp:71
ocp.U
U
Definition:
ocp.py:61
pinocchio::helper::argument_type
Definition:
include/pinocchio/macros.hpp:42
pinocchio
Main pinocchio namespace.
Definition:
timings.cpp:28
pinocchio
Author(s):
autogenerated on Tue Feb 13 2024 03:43:59