Skip to content

Commit

Permalink
Fix wt_200k_G.c "initializer element is not constant" error with GCC …
Browse files Browse the repository at this point in the history
…< 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.
  • Loading branch information
dwatteau committed Dec 6, 2024
1 parent 290e469 commit f65a97f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions arm-wt-22k/lib_src/wt_200k_G.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f65a97f

Please sign in to comment.