macros.h
Go to the documentation of this file.
1 // g2o - General Graph Optimization
2 // Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright notice,
10 // this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above copyright
12 // notice, this list of conditions and the following disclaimer in the
13 // documentation and/or other materials provided with the distribution.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
18 // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 
27 #ifndef G2O_MACROS_H
28 #define G2O_MACROS_H
29 
30 #ifndef DEG2RAD
31 #define DEG2RAD(x) ((x) * 0.01745329251994329575)
32 #endif
33 
34 #ifndef RAD2DEG
35 #define RAD2DEG(x) ((x) * 57.29577951308232087721)
36 #endif
37 
38 // GCC the one and only
39 #if defined(__GNUC__)
40 # define G2O_ATTRIBUTE_CONSTRUCTOR(func) \
41  static void func(void)__attribute__ ((constructor)); \
42  static void func(void)
43 
44 # define G2O_ATTRIBUTE_UNUSED __attribute__((unused))
45 # define G2O_ATTRIBUTE_FORMAT12 __attribute__ ((format (printf, 1, 2)))
46 # define G2O_ATTRIBUTE_FORMAT23 __attribute__ ((format (printf, 2, 3)))
47 # define G2O_ATTRIBUTE_WARNING(func) func __attribute__((warning))
48 # define G2O_ATTRIBUTE_DEPRECATED(func) func __attribute__((deprecated))
49 
50 #ifdef ANDROID
51 # define g2o_isnan(x) isnan(x)
52 # define g2o_isinf(x) isinf(x)
53 # define g2o_isfinite(x) isfinite(x)
54 #else
55 # define g2o_isnan(x) std::isnan(x)
56 # define g2o_isinf(x) std::isinf(x)
57 # define g2o_isfinite(x) std::isfinite(x)
58 #endif
59 
60 // MSVC on Windows
61 #elif defined _MSC_VER
62 # define __PRETTY_FUNCTION__ __FUNCTION__
63 
74 # define G2O_ATTRIBUTE_CONSTRUCTOR(f) \
75  __pragma(section(".CRT$XCU",read)) \
76  static void __cdecl f(void); \
77  __declspec(allocate(".CRT$XCU")) void (__cdecl*f##_)(void) = f; \
78  static void __cdecl f(void)
79 
80 # define G2O_ATTRIBUTE_UNUSED
81 # define G2O_ATTRIBUTE_FORMAT12
82 # define G2O_ATTRIBUTE_FORMAT23
83 # define G2O_ATTRIBUTE_WARNING(func) func
84 # define G2O_ATTRIBUTE_DEPRECATED(func) func
85 
86 #include <float.h>
87 
88 # define g2o_isnan(x) _isnan(x)
89 # define g2o_isinf(x) (_finite(x) == 0)
90 # define g2o_isfinite(x) (_finite(x) != 0)
91 
92 // unknown compiler
93 #else
94 # ifndef __PRETTY_FUNCTION__
95 # define __PRETTY_FUNCTION__ ""
96 # endif
97 # define G2O_ATTRIBUTE_CONSTRUCTOR(func) func
98 # define G2O_ATTRIBUTE_UNUSED
99 # define G2O_ATTRIBUTE_FORMAT12
100 # define G2O_ATTRIBUTE_FORMAT23
101 # define G2O_ATTRIBUTE_WARNING(func) func
102 # define G2O_ATTRIBUTE_DEPRECATED(func) func
103 
104 #include <math.h>
105 #define g2o_isnan(x) isnan(x)
106 #define g2o_isinf(x) isinf(x)
107 #define g2o_isfinite(x) isfinite(x)
108 
109 #endif
110 
111 // some macros that are only useful for c++
112 #ifdef __cplusplus
113 
114 #define G2O_FSKIP_LINE(f) \
115  {char c=' ';while(c != '\n' && f.good() && !(f).eof()) (f).get(c);}
116 
117 #ifndef PVAR
118  #define PVAR(s) \
119  #s << " = " << (s) << std::flush
120 #endif
121 
122 #ifndef PVARA
123 #define PVARA(s) \
124  #s << " = " << RAD2DEG(s) << "deg" << std::flush
125 #endif
126 
127 #ifndef FIXED
128 #define FIXED(s) \
129  std::fixed << s << std::resetiosflags(std::ios_base::fixed)
130 #endif
131 
132 #endif // __cplusplus
133 
134 #endif


orb_slam2_ros
Author(s):
autogenerated on Wed Apr 21 2021 02:53:05