APM:Libraries
AP_HAL_Macros.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*
4  macros to allow code to build on multiple platforms more easily
5  */
6 
7 #ifdef __GNUC__
8  #define WARN_IF_UNUSED __attribute__ ((warn_unused_result))
9 #else
10  #define WARN_IF_UNUSED
11 #endif
12 
13 // use this to avoid issues between C++11 with NuttX and C++10 on
14 // other platforms.
15 #if !(defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L)
16 # define constexpr const
17 #endif
18 
19 #define NORETURN __attribute__ ((noreturn))
20 
21 #if CONFIG_HAL_BOARD == HAL_BOARD_SITL || CONFIG_HAL_BOARD == HAL_BOARD_LINUX
22 /*
23  allow double maths on Linux and SITL to avoid problems with system headers
24  */
25 #define ALLOW_DOUBLE_MATH_FUNCTIONS
26 #endif
27 
28 #if !defined(ALLOW_DOUBLE_MATH_FUNCTIONS)
29 /* give warnings if we use double precision maths functions without
30  specifying ALLOW_DOUBLE_TRIG_FUNCTIONS. Code should use the
31  equivalent f function instead (eg. use cosf() instead of
32  cos()). Individual cpp files that really do need double precision
33  should define ALLOW_DOUBLE_TRIG_FUNCTIONS before including
34  AP_Math.h
35 */
36 #define sin(x) DO_NOT_USE_DOUBLE_MATHS()
37 #define cos(x) DO_NOT_USE_DOUBLE_MATHS()
38 #define tan(x) DO_NOT_USE_DOUBLE_MATHS()
39 #define acos(x) DO_NOT_USE_DOUBLE_MATHS()
40 #define asin(x) DO_NOT_USE_DOUBLE_MATHS()
41 #define atan(x) DO_NOT_USE_DOUBLE_MATHS()
42 #define atan2(x,y) DO_NOT_USE_DOUBLE_MATHS()
43 #define exp(x) DO_NOT_USE_DOUBLE_MATHS()
44 #define pow(x,y) DO_NOT_USE_DOUBLE_MATHS()
45 #define sqrt(x) DO_NOT_USE_DOUBLE_MATHS()
46 #define log2(x) DO_NOT_USE_DOUBLE_MATHS()
47 #define log10(x) DO_NOT_USE_DOUBLE_MATHS()
48 #define ceil(x) DO_NOT_USE_DOUBLE_MATHS()
49 #define floor(x) DO_NOT_USE_DOUBLE_MATHS()
50 #define round(x) DO_NOT_USE_DOUBLE_MATHS()
51 #if !HAL_WITH_UAVCAN
52 // we should do log() and fabs() as well, but can't because of a conflict in uavcan
53 #define log(x) DO_NOT_USE_DOUBLE_MATHS()
54 #define fabs(x) DO_NOT_USE_DOUBLE_MATHS()
55 #endif
56 #endif
57