From f65a97f42574ae5c1782bac0b842707ae6854b64 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 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..ee609c39 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; +enum { sampleRate = 0xAC44 }; #else -const EAS_U32 sampleRate = 0x5622; +enum { sampleRate = 0x5622 }; #endif const S_EAS easSoundLib = { 0x01534145, #if defined (_8_BIT_SAMPLES) - 0x00100000 | sampleRate, + 0x00100000 | (EAS_U32)sampleRate, #else //_16_BIT_SAMPLES - 0x00200000 | sampleRate, + 0x00200000 | (EAS_U32)sampleRate, #endif eas_banks,