From 36f347e1b55c7cb2116d9db4265e9018d934d2d8 Mon Sep 17 00:00:00 2001 From: Hugo Pontes Date: Sun, 1 Oct 2023 10:35:58 +0100 Subject: [PATCH] Add do while (0) to Id and ID macros --- src/trice.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/trice.h b/src/trice.h index 23e4456ad..e1a0d5145 100644 --- a/src/trice.h +++ b/src/trice.h @@ -837,12 +837,12 @@ static inline uint64_t aDouble( double x ){ //! ID writes 14-bit id with 11 as 2 most significant bits, followed by a 32-bit stamp. //! 11iiiiiiI TT | TT (NC) | ... //! C000 = 1100 0000 0000 0000 -#define ID(n) { uint32_t ts = TriceStamp32(); TRICE_PUT16( (0xC000|(n))); TRICE_PUT1616(ts); } +#define ID(n) do { uint32_t ts = TriceStamp32(); TRICE_PUT16( (0xC000|(n))); TRICE_PUT1616(ts); } while(0) //! Id writes 14-bit id with 10 as 2 most significant bits two times, followed by a 16-bit stamp. //! 10iiiiiiI 10iiiiiiI | TT (NC) | ... //! 8000 = 1000 0000 0000 0000 -#define Id(n) { uint16_t ts = TriceStamp16(); TRICE_PUT((0x80008000|((n)<<16)|(n))); TRICE_PUT16(ts); } +#define Id(n) do { uint16_t ts = TriceStamp16(); TRICE_PUT((0x80008000|((n)<<16)|(n))); TRICE_PUT16(ts); } while(0) //! id writes 14-bit id with 01 as 2 most significant bits, followed by no stamp. //! 01iiiiiiI (NC) | ...