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 a #define (or an enum) for the `sampleRate` value is enough for
older GCC releases.
  • Loading branch information
dwatteau committed Dec 9, 2024
1 parent 290e469 commit b2a987e
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;
#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,
Expand Down

0 comments on commit b2a987e

Please sign in to comment.