xtensa compiler: case label does not reduce to an integer constant
Posted: Wed Apr 27, 2022 2:09 pm
Hello,
When compiling the simple program below with a macro as a case label, I receive the error:
Compile command:
GCC compile shows no warnings or errors.
This is on a Mac OSX 12.3.1
Xtensa compiler: xtensa-esp32s3-elf-gcc (crosstool-NG esp-2021r2) 8.4.0
Gcc compiler: Apple clang version 13.1.6 (clang-1316.0.21.2.3)
Thoughts?
Thanks!
When compiling the simple program below with a macro as a case label, I receive the error:
The error only happens with the xtensa-esp32s3-elf-gcc compiler. This does not happen with plain gcc.case label does not reduce to an integer constant
Code: Select all
#include <stdio.h>
// #include <stdlib.h>
#include <stdint.h>
#include <math.h>
#include <string.h>
#define HTST(s, i, x) (s[2])
int main() {
switch(12) {
case HTST("anything", 0, 0):
printf("anything!");
break;
default:
printf("DEFAIULT");
}
}
Code: Select all
> xtensa-esp32s3-elf-gcc t.c
t.c: In function 'main':
t.c:12:6: error: case label does not reduce to an integer constant
case HTST("anything", 0, 0):
^~~~
This is on a Mac OSX 12.3.1
Xtensa compiler: xtensa-esp32s3-elf-gcc (crosstool-NG esp-2021r2) 8.4.0
Gcc compiler: Apple clang version 13.1.6 (clang-1316.0.21.2.3)
Thoughts?
Thanks!