YARP
Yet Another Robot Platform
system.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef YARP_CONFIG_SYSTEM_H
8 #define YARP_CONFIG_SYSTEM_H
9 
10 // System headers
11 #define YARP_HAS_EXECINFO_H
12 #define YARP_HAS_SYS_WAIT_H
13 #define YARP_HAS_SYS_TYPES_H
14 #define YARP_HAS_SYS_PRCTL_H
15 /* #undef YARP_HAS_CSIGNAL */
16 #define YARP_HAS_SIGNAL_H
17 #define YARP_HAS_SYS_SIGNAL_H
18 #define YARP_HAS_NETDB_H
19 #define YARP_HAS_DLFCN_H
20 #define YARP_HAS_IFADDRS_H
21 
22 // Size of pointers
23 #define YARP_POINTER_SIZE 8
24 
25 
27 
91 
92 
93 #if defined(_MSC_VER)
94  // see https://support.microsoft.com/kb/155196/en-us
95  #define __YARP_STR2(x) #x
96  #define __YARP_STR1(x) __YARP_STR2(x)
97  #define __YARP_LOC __FILE__ "("__STR1__(__LINE__)")"
98  #define YARP_COMPILER_MESSAGE(x) __pragma(message(__LOC__ " : msg" #x))
99  #define YARP_COMPILER_WARNING(x) __pragma(message(__LOC__ " : warning msg" #x))
100  #define YARP_COMPILER_ERROR(x) __pragma(message(__LOC__ " : error msg" #x))
101 #elif defined(__GNUC__)
102  // see https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html
103  #define __YARP_DO_PRAGMA(x) _Pragma (#x)
104  #define YARP_COMPILER_MESSAGE(x) __YARP_DO_PRAGMA(message #x)
105  #define YARP_COMPILER_WARNING(x) __YARP_DO_PRAGMA(GCC warning #x)
106  #define YARP_COMPILER_ERROR(x) __YARP_DO_PRAGMA(GCC error #x)
107 #else
108  #define YARP_COMPILER_MESSAGE(x)
109  #define YARP_COMPILER_WARNING(x)
110  #define YARP_COMPILER_ERROR(x)
111 #endif
112 
113 #ifndef YARP_NO_DEPRECATED_WARNINGS
114  #define YARP_COMPILER_DEPRECATED_WARNING(x) YARP_COMPILER_WARNING(x)
115 #else
116  #define YARP_COMPILER_DEPRECATED_WARNING(x)
117 #endif
118 
119 
121 
146 
147 
148 #if defined(CYGWIN)
149 # define YARP_BEGIN_PACK \
150  _Pragma("pack(1)")
151 # define YARP_END_PACK \
152  _Pragma("pack()")
153 #elif defined(_MSC_VER)
154 // use packing and make no apologies about it
155 # define YARP_BEGIN_PACK \
156  __pragma(warning(push)) \
157  __pragma(warning(disable:4103)) \
158  __pragma(pack(push, 1))
159 # define YARP_END_PACK \
160  __pragma(pack(pop)) \
161  __pragma(warning(pop))
162 #elif defined(__linux__)
163 # define YARP_BEGIN_PACK \
164  _Pragma("pack(1)")
165 # define YARP_END_PACK _Pragma("pack()")
166 #elif defined(__DARWIN__)
167 # define YARP_BEGIN_PACK \
168  _Pragma("pack(1)")
169 # define YARP_END_PACK \
170  _Pragma("pack()")
171 #elif defined(__APPLE__)
172 # define YARP_BEGIN_PACK \
173  _Pragma("pack(1)")
174 # define YARP_END_PACK \
175  _Pragma("pack()")
176 #elif defined(__QNX4__)
177 # define YARP_BEGIN_PACK \
178  _Pragma(" pack (push) ;") \
179  _Pragma(" pack (1) ;")
180 # define YARP_END_PACK \
181  _Pragma(" pack (pop) ;")
182 #elif defined(__QNX6__)
183 //_Pragma("align 1")
184 # define YARP_BEGIN_PACK \
185  _Pragma("pack(1)")
186 //_Pragma("align 0")
187 # define YARP_END_PACK \
188  _Pragma("pack()")
189 #else
190 # define YARP_BEGIN_PACK
191 # define YARP_END_PACK
192 #endif
193 
194 
196 
302 
303 
304 #if defined(_MSC_VER)
305 # define YARP_WARNING_PUSH __pragma(warning(push))
306 # define YARP_WARNING_POP __pragma(warning(pop))
307 # define YARP_DISABLE_DEPRECATED_WARNING __pragma(warning(disable:4996))
308 # define YARP_DISABLE_DLL_INTERFACE_WARNING __pragma(warning(disable:4251))
309 # define YARP_SUPPRESS_DLL_INTERFACE_WARNING __pragma(warning(suppress:4251))
310 # define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(x) __pragma(warning(suppress:4251)) \
311  x
312 # define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARGS(...) __pragma(warning(suppress:4251)) \
313  __VA_ARGS__
314 #elif defined(__clang__)
315 # define YARP_WARNING_PUSH _Pragma("clang diagnostic push")
316 # define YARP_WARNING_POP _Pragma("clang diagnostic pop")
317 # define YARP_DISABLE_DEPRECATED_WARNING _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
318 # define YARP_DISABLE_DLL_INTERFACE_WARNING
319 # define YARP_SUPPRESS_DLL_INTERFACE_WARNING
320 # define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(x) x
321 # define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARGS(...) __VA_ARGS__
322 #elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
323 # define YARP_WARNING_PUSH _Pragma("GCC diagnostic push")
324 # define YARP_WARNING_POP _Pragma("GCC diagnostic pop")
325 # define YARP_DISABLE_DEPRECATED_WARNING _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
326 # define YARP_DISABLE_DLL_INTERFACE_WARNING
327 # define YARP_SUPPRESS_DLL_INTERFACE_WARNING
328 # define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(x) x
329 # define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARGS(...) __VA_ARGS__
330 #else
331 # define YARP_WARNING_PUSH
332 # define YARP_WARNING_POP
333 # define YARP_DISABLE_DEPRECATED_WARNING
334 # define YARP_DISABLE_DLL_INTERFACE_WARNING
335 # define YARP_SUPPRESS_DLL_INTERFACE_WARNING
336 # define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(x) x
337 # define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARGS(...) __VA_ARGS__
338 #endif
339 
340 
341 // Bug in GCC < 6
342 // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43407
343 #if defined(__GNUC__) && (__GNUC__ < 6)
344 # define YARP_DISABLE_CLASS_ENUM_API_WARNING _Pragma("GCC diagnostic ignored \"-Wattributes\"")
345 #else
346 # define YARP_DISABLE_CLASS_ENUM_API_WARNING
347 #endif
348 
349 #endif