MRPT  2.0.4
common.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
12 /* ------------------------------------
13  Disable some warnings
14  ------------------------------------ */
15 #if defined(_MSC_VER)
16 #pragma warning(disable : 4127) // Disable conditional expression is constant
17 // (it shows up in templates where it's
18 // correct)
19 #pragma warning(disable : 4244) // argument conversion "possible loss of data"
20 #pragma warning(disable : 4503) // (Compiler: Visual C++ 2010) Disable warning
21 // for too long decorated name
22 #pragma warning(disable : 4714) // force inlined -> not inlined (in Eigen3)
23 #pragma warning(disable : 4267) // truncation size_t -> type
24 #pragma warning(disable : 4290) // Visual C++ does not implement decl.
25 // specifiers: throw(A,B,...)
26 #pragma warning(disable : 4251) // Visual C++ 2003+ warnings on STL classes
27 // when exporting to DLL...
28 #pragma warning(disable : 4275) // DLL export class derived from STL
29 #pragma warning( \
30  disable : 4251) // Warnings are emited even if a DLL export class
31 // contains a *private* STL field (?)
32 #if (_MSC_VER >= 1400)
33 // MS believes they have the right to deprecate functions in the C++ Standard
34 // STL... disable their warnings:
35 #ifndef _SCL_SECURE_NO_WARNINGS
36 #define _SCL_SECURE_NO_WARNINGS
37 #endif
38 // For the new secure library in VC++8
39 #if !defined(_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES)
40 #define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES 1
41 #endif
42 #endif
43 #endif
44 
45 // Avoid conflicting declaration of max macro in windows headers
46 #if defined(_WIN32) && !defined(NOMINMAX)
47 #define NOMINMAX
48 #ifdef max
49 #undef max
50 #undef min
51 #endif
52 #endif
53 
54 // Generic constants and defines:
55 // ---------------------------------------------------------
56 // M_PI: Rely on standard <cmath>
57 #ifndef M_2PI
58 #define M_2PI 6.283185307179586476925286766559 // The 2*PI constant
59 #endif
60 
61 #define M_PIf 3.14159265358979f
62 #define M_2PIf 6.28318530717959f
63 
64 /** MRPT_CHECK_GCC_VERSION(MAJ,MIN) */
65 #if defined(__GNUC__) && defined(__GNUC_MINOR__)
66 #define MRPT_CHECK_GCC_VERSION(major, minor) \
67  ((__GNUC__ > (major)) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
68 #else
69 #define MRPT_CHECK_GCC_VERSION(major, minor) 0
70 #endif
71 
72 /** MRPT_CHECK_VISUALC_VERSION(Version) Version=8 for 2005, 9=2008, 10=2010,
73  * 11=2012, 12=2013, 14=2015 */
74 #ifndef _MSC_VER
75 #define MRPT_VISUALC_VERSION(major) 0
76 #define MRPT_CHECK_VISUALC_VERSION(major) 0
77 #else
78 /* (From wxWidgets macros):
79 Things used to be simple with the _MSC_VER value and the version number
80 increasing in lock step, but _MSC_VER value of 1900 is VC14 and not the
81 non existing (presumably for the superstitious reasons) VC13, so we now
82 need to account for this with an extra offset.
83 */
84 #define MRPT_VISUALC_VERSION(major) \
85  ((6 + (major >= 14 ? (-1) : 0) + major) * 100)
86 #define MRPT_CHECK_VISUALC_VERSION(major) \
87  (_MSC_VER >= MRPT_VISUALC_VERSION(major))
88 #endif
89 
90 #ifndef __has_feature
91 #define __has_feature(x) 0 // Compatibility with non-clang compilers.
92 #endif
93 #ifndef __has_extension
94 #define __has_extension __has_feature // Compatibility with pre-3.0 compilers.
95 #endif
96 
97 /** Declare MRPT_TODO(message) */
98 #if defined(_MSC_VER)
99 #define MRPT_DO_PRAGMA(x) __pragma(x)
100 #define __STR2__(x) #x
101 #define __STR1__(x) __STR2__(x)
102 #define __MSVCLOC__ __FILE__ "("__STR1__(__LINE__) ") : "
103 #define MRPT_MSG_PRAGMA(_msg) MRPT_DO_PRAGMA(message(__MSVCLOC__ _msg))
104 #elif defined(__GNUC__)
105 #define MRPT_DO_PRAGMA(x) _Pragma(#x)
106 #define MRPT_MSG_PRAGMA(_msg) MRPT_DO_PRAGMA(message(_msg))
107 #else
108 #define MRPT_DO_PRAGMA(x)
109 #define MRPT_MSG_PRAGMA(_msg)
110 #endif
111 
112 #define MRPT_WARNING(x) MRPT_MSG_PRAGMA("Warning: " x)
113 #define MRPT_TODO(x) MRPT_MSG_PRAGMA("TODO: " x)
114 
115 // Define a decl. modifier for printf-like format checks at compile time:
116 #ifdef __GNUC__
117 #define MRPT_printf_format_check(_FMT_, _VARARGS_) \
118  __attribute__((__format__(__printf__, _FMT_, _VARARGS_)))
119 #else
120 #define MRPT_printf_format_check(_FMT_, _VARARGS_)
121 #endif
122 // Define a decl. modifier for scanf-like format checks at compile time:
123 #ifdef __GNUC__
124 #define MRPT_scanf_format_check(_FMT_, _VARARGS_) \
125  __attribute__((__format__(__scanf__, _FMT_, _VARARGS_)))
126 #else
127 #define MRPT_scanf_format_check(_FMT_, _VARARGS_)
128 #endif
129 
130 /** A macro for obtaining the name of the current function: */
131 #if defined(_MSC_VER) && (_MSC_VER >= 1300)
132 #define __CURRENT_FUNCTION_NAME__ __FUNCTION__
133 #else
134 #define __CURRENT_FUNCTION_NAME__ __PRETTY_FUNCTION__
135 #endif
136 
137 // Define a decl. modifier for printf-like format checks at compile time:
138 #ifdef __GNUC__
139 #define MRPT_printf_format_check(_FMT_, _VARARGS_) \
140  __attribute__((__format__(__printf__, _FMT_, _VARARGS_)))
141 #else
142 #define MRPT_printf_format_check(_FMT_, _VARARGS_)
143 #endif
144 
145 // Define a decl. modifier for scanf-like format checks at compile time:
146 #ifdef __GNUC__
147 #define MRPT_scanf_format_check(_FMT_, _VARARGS_) \
148  __attribute__((__format__(__scanf__, _FMT_, _VARARGS_)))
149 #else
150 #define MRPT_scanf_format_check(_FMT_, _VARARGS_)
151 #endif
152 
153 /** Tells the compiler we really want to inline that function */
154 #if (defined _MSC_VER) || (defined __INTEL_COMPILER)
155 #define MRPT_FORCE_INLINE __forceinline
156 #else
157 #define MRPT_FORCE_INLINE inline
158 #endif
159 
160 /** Determines whether this is an X86 or AMD64 platform */
161 #if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || \
162  defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64) || \
163  defined(__i386__) || defined(__i386) || defined(_M_I86) || \
164  defined(i386) || defined(_M_IX86) || defined(_X86_)
165 #define MRPT_IS_X86_AMD64 1
166 #endif



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020