PX4 Firmware
PX4 Autopilot Software http://px4.io
test_macros.hpp
Go to the documentation of this file.
1 /**
2  * @file test_marcos.hpp
3  *
4  * Helps with cmake testing.
5  *
6  * @author James Goppert <james.goppert@gmail.com>
7  * Pavel Kirienko <pavel.kirienko@zubax.com>
8  */
9 #pragma once
10 
11 #include <cstdio>
12 #include <cmath> // cmath has to be introduced BEFORE we poison the C library identifiers
13 
14 #define TEST(X) if(!(X)) { fprintf(stderr, "test failed on %s:%d\n", __FILE__, __LINE__); return -1;}
15 
16 /**
17  * This construct is needed to catch any unintended use of the C standard library.
18  * Feel free to extend the list of poisoned identifiers with as many C functions as possible.
19  * The current list was constructed by means of automated parsing of http://en.cppreference.com/w/c/numeric/math
20  */
21 #ifdef __GNUC__
22 
23 // float functions
24 # pragma GCC poison fabsf fmodf
25 # pragma GCC poison remainderf remquof fmaf fmaxf fminf fdimf fnanf expf
26 # pragma GCC poison exp2f expm1f logf log10f log2f log1pf powf sqrtf cbrtf
27 # pragma GCC poison hypotf sinf cosf tanf asinf acosf atanf atan2f sinhf
28 # pragma GCC poison coshf tanhf asinhf acoshf atanhf erff erfcf tgammaf
29 # pragma GCC poison lgammaf ceilf floorf truncf roundf nearbyintf rintf
30 # pragma GCC poison frexpf ldexpf modff scalbnf ilogbf logbf nextafterf
31 # pragma GCC poison copysignf
32 
33 // the list of double functions is missing because otherwise most functions from std:: would be also poisoned,
34 // which we don't want
35 
36 // long double functions
37 # pragma GCC poison fabsl fabsl fabsl fmodl
38 # pragma GCC poison remainderl remquol fmal fmaxl fminl fdiml fnanl expl
39 # pragma GCC poison exp2l expm1l logl log10l log2l log1pl powl sqrtl cbrtl
40 # pragma GCC poison hypotl sinl cosl tanl asinl acosl atanl atan2l sinhl
41 # pragma GCC poison coshl tanhl asinhl acoshl atanhl erfl erfcl tgammal
42 # pragma GCC poison lgammal ceill floorl truncl roundl nearbyintl rintl
43 # pragma GCC poison frexpl ldexpl modfl scalbnl ilogbl logbl nextafterl
44 # pragma GCC poison copysignl
45 
46 #endif