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