f = 23.0f;
constexpr float g = 33.0f;
fesetround(FE_TOWARDZERO);
constexpr float h = f / g;
printf("%f\n", h);
}
I tried compiling this sample from cppreference(https://en.cppreference.com/w/c/language/constexpr) with the following command
gcc -std=c2x main.c -o main
But I'm getting error.
main.c: In function ‘main’:
main.c:6:5: error: ‘constexpr’ undeclared (first use in this function)
6 | constexpr float f = 23.0f;
| ^~~~~~~~~
main.c:6:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:6:14: error: expected ‘;’ before ‘float’
6 | constexpr float f = 23.0f;
| ^~~~~~
| ;
main.c:7:14: error: expected ‘;’ before ‘float’
7 | constexpr float g = 33.0f;
| ^~~~~~
| ;
main.c:9:14: error: expected ‘;’ before ‘float’
9 | constexpr float h = f / g; // is not affected by fesetround() above
| ^~~~~~
| ;
main.c:10:20: error: ‘h’ undeclared (first use in this function)
10 | printf("%f\n", h);
| ^
I'm using gcc (Debian 12.2.0-14) 12.2.0.
constexpr is introduced in the C23 standard right ?
https://godbolt.org/z/P5v1z5M9v
Ah yeah, seems like gcc 12.2 doesn't have the support.
Debian Is not a good distro for desktop and above all developong, is too old, try Fedora or Arch Linux(for example) or other distro with software not obsolete.
I'm actually using Debian under WSL2
u can use Debian sid/testing...
Unstable Is Better for desktop
Обсуждают сегодня