diff options
author | David Sidrane <david_s5@nscdg.com> | 2014-12-29 15:14:18 -1000 |
---|---|---|
committer | David Sidrane <david_s5@nscdg.com> | 2015-04-07 07:12:03 -1000 |
commit | 9a524f21859ed80a0b9d7f879d0136500bad9be8 (patch) | |
tree | 835b8ccc8d92beeb8cd075c4a9c8bb13f2cc0e6d /src | |
parent | a1f5e521044d4c9f28e8c150b1099c78d30c7864 (diff) | |
download | px4-firmware-9a524f21859ed80a0b9d7f879d0136500bad9be8.tar.gz px4-firmware-9a524f21859ed80a0b9d7f879d0136500bad9be8.tar.bz2 px4-firmware-9a524f21859ed80a0b9d7f879d0136500bad9be8.zip |
Cleanup CCASSERT: Use built-in static_assert if it is available and
supperss the unused typedef waning or (-Werror)
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/systemlib/px4_macros.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/modules/systemlib/px4_macros.h b/src/modules/systemlib/px4_macros.h index 32eaf266d..956355b2c 100644 --- a/src/modules/systemlib/px4_macros.h +++ b/src/modules/systemlib/px4_macros.h @@ -51,6 +51,7 @@ * CCASSERT(predicate) Will generate a compile time error it the * predicate is false */ +#include <assert.h> #ifndef _PX4_MACROS_H #define _PX4_MACROS_H @@ -86,10 +87,14 @@ #endif #if !defined(CCASSERT) -#define CCASSERT(predicate) _x_CCASSERT_LINE(predicate, __LINE__) -#if !defined(_x_CCASSERT_LINE) -#define _x_CCASSERT_LINE(predicate, line) typedef char CAT(constraint_violated_on_line_,line)[2*((predicate)!=0)-1]; -#endif +#if defined(static_assert) +# define CCASSERT(predicate) static_assert(predicate) +# else +# define CCASSERT(predicate) _x_CCASSERT_LINE(predicate, __LINE__) +# if !defined(_x_CCASSERT_LINE) +# define _x_CCASSERT_LINE(predicate, line) typedef char CAT(constraint_violated_on_line_,line)[2*((predicate)!=0)-1] __attribute__ ((unused)) ; +# endif +# endif #endif |