From b2a987e7273e65ce4c7bc7dad8c37fbbb4aeda3e Mon Sep 17 00:00:00 2001 From: Donovan Watteau Date: Fri, 6 Dec 2024 14:50:14 +0100 Subject: [PATCH] Fix wt_200k_G.c "initializer element is not constant" error with GCC < 8.1 Building with GCC < 8.1 would give the following error: arm-wt-22k/lib_src/wt_200k_G.c:114:5: error: initializer element is not constant 0x00200000 | sampleRate, ^~~~~~~~~~ arm-wt-22k/lib_src/wt_200k_G.c:114:5: note: (near initialization for 'easSoundLib.libAttr') See also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69960#c18 Using a #define (or an enum) for the `sampleRate` value is enough for older GCC releases. --- arm-wt-22k/lib_src/wt_200k_G.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arm-wt-22k/lib_src/wt_200k_G.c b/arm-wt-22k/lib_src/wt_200k_G.c index 0bd9c8b9..03f46997 100644 --- a/arm-wt-22k/lib_src/wt_200k_G.c +++ b/arm-wt-22k/lib_src/wt_200k_G.c @@ -99,19 +99,20 @@ const S_BANK eas_banks[] = *---------------------------------------------------------------------------- */ +// Can't be a 'const EAS_U32' before GCC 8.1 #ifdef _SAMPLE_RATE_44100 -const EAS_U32 sampleRate = 0xAC44; +#define SAMPLE_RATE 0xAC44 #else -const EAS_U32 sampleRate = 0x5622; +#define SAMPLE_RATE 0x5622 #endif const S_EAS easSoundLib = { 0x01534145, #if defined (_8_BIT_SAMPLES) - 0x00100000 | sampleRate, + 0x00100000 | SAMPLE_RATE, #else //_16_BIT_SAMPLES - 0x00200000 | sampleRate, + 0x00200000 | SAMPLE_RATE, #endif eas_banks,