From dae2dc6003bc0cbd2de26f006aa6133b1f55c5cf Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 18 Jan 2025 20:10:35 +0100 Subject: [PATCH] tests/unit-test.h.in: satisfy some compilers that UT_BITS_ADDRESS_INVALID_REQUEST_LENGTH is initialized correctly with constexpr Signed-off-by: Jim Klimov --- tests/unit-test.h.in | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/unit-test.h.in b/tests/unit-test.h.in index afb33e23..3d83967a 100644 --- a/tests/unit-test.h.in +++ b/tests/unit-test.h.in @@ -27,10 +27,17 @@ #define SERVER_ID 17 #define INVALID_SERVER_ID 18 -const uint16_t UT_BITS_ADDRESS = 0x130; +/* https://stackoverflow.com/a/3025142/4715872 + * ...in section 6.6, the spec defines what must considered + * a constant expression. No where does it state that a + * const variable must be considered a constant expression. + * It is legal for a compiler to extend this... + */ +#define UT_BITS_ADDRESS_VAL 0x130 +const uint16_t UT_BITS_ADDRESS = UT_BITS_ADDRESS_VAL; const uint16_t UT_BITS_NB = 0x25; const uint8_t UT_BITS_TAB[] = { 0xCD, 0x6B, 0xB2, 0x0E, 0x1B }; -const uint16_t UT_BITS_ADDRESS_INVALID_REQUEST_LENGTH = UT_BITS_ADDRESS + 2; +const uint16_t UT_BITS_ADDRESS_INVALID_REQUEST_LENGTH = UT_BITS_ADDRESS_VAL + 2; const uint16_t UT_INPUT_BITS_ADDRESS = 0x1C4; const uint16_t UT_INPUT_BITS_NB = 0x16;