From 0d3e66fa0a274d2482d6bbb6dea80508dcd614de Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 28 Mar 2018 14:30:32 +0700 Subject: [PATCH] clean up static assert --- tinyusb/common/tusb_compiler.h | 10 +++++----- tinyusb/common/verify.h | 15 --------------- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/tinyusb/common/tusb_compiler.h b/tinyusb/common/tusb_compiler.h index 62a34344..8c0e7502 100644 --- a/tinyusb/common/tusb_compiler.h +++ b/tinyusb/common/tusb_compiler.h @@ -50,18 +50,18 @@ #define XSTRING_CONCAT_(a, b) STRING_CONCAT_(a, b) ///< expand then concat //--------------------------------------------------------------------+ -// Compile-time Assert +// Compile-time Assert (use VERIFY_STATIC to avoid name conflict) //--------------------------------------------------------------------+ -#ifdef __ICCARM__ +#if defined(__ICCARM__) || (__STDC_VERSION__ >= 201112L ) #define VERIFY_STATIC static_assert #else #if defined __COUNTER__ && __COUNTER__ != __COUNTER__ - #define _ASSERT_COUNTER __COUNTER__ + #define _VERIFY_COUNTER __COUNTER__ #else - #define _ASSERT_COUNTER __LINE__ + #define _VERIFY_COUNTER __LINE__ #endif - #define VERIFY_STATIC(const_expr, message) enum { XSTRING_CONCAT_(static_assert_, _ASSERT_COUNTER) = 1/(!!(const_expr)) } + #define VERIFY_STATIC(const_expr, _mess) enum { XSTRING_CONCAT_(_verify_static_, _VERIFY_COUNTER) = 1/(!!(const_expr)) } #endif // allow debugger to watch any module-wide variables anywhere diff --git a/tinyusb/common/verify.h b/tinyusb/common/verify.h index 5ee80627..a5eeb5ae 100644 --- a/tinyusb/common/verify.h +++ b/tinyusb/common/verify.h @@ -51,21 +51,6 @@ #define GET_3RD_ARG(arg1, arg2, arg3, ...) arg3 #define GET_4TH_ARG(arg1, arg2, arg3, arg4, ...) arg4 -//--------------------------------------------------------------------+ -// Compile-time Verify (like assert static) -//--------------------------------------------------------------------+ -#ifdef __ICCARM__ - #define VERIFY_STATIC static_assert -#else - #if defined __COUNTER__ && __COUNTER__ != __COUNTER__ - #define _VERIFY_COUNTER __COUNTER__ - #else - #define _VERIFY_COUNTER __LINE__ - #endif - - #define VERIFY_STATIC(const_expr, _mess) enum { XSTRING_CONCAT_(_verify_static_, _VERIFY_COUNTER) = 1/(!!(const_expr)) } -#endif - //--------------------------------------------------------------------+ // VERIFY Helper //--------------------------------------------------------------------+