Похожие чаты

Main.C #Include <fenv.h> #include <stdio.h> int main(void) { constexpr float

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 ?

9 ответов

19 просмотров

https://godbolt.org/z/P5v1z5M9v

mito 😼- Автор вопроса
²
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.

mito 😼- Автор вопроса
David Costa
u can use Debian sid/testing...

Unstable Is Better for desktop

Похожие вопросы

Обсуждают сегодня

I know it seems like "fud" but its just common sense imho. Blockchains in their fundamental nature distribute the value creation function to the community but in Kadena its...
Bright Uncle Stephen EqualBet
13
коллеги привет. уже второй день бьемся об заклад с одной ошибкой, может вы сталкивались с таки странным поведением? есть тестовый сервер, на который паблишим релизную версию W...
Magzhan
11
кому не сложно распишите пожалуйста для какой цели тут вот эти скобки и в них пихается указатель?
Михаил Helper
15
Hello, I am Ashamer from UNCX, a DeFi service provider. I am contacting you to ask if there is any room for a potential collaboration. Is there anyone whom I can potentially t...
Ashamer
17
Какие дистрибутивы Linux чаще всего работают в качестве серверов и почему?
Alex
27
А кто-то пробовал, уезжая из Эстонии получить э-рез и продолжить вести предпринимательскую деятельность внутри Эстонии, используя свой OÜ?
Lalalashechki Lalala
62
я не магистр хаскеля, но разве не может лейзи тип конвертнуться в не-лейзи запросив вычисление содержимого прям при инициализации?
deadgnom32 λ madao
100
Комрады, посоветуйте, куда копать? Стал прикручивать кастомизацию тем. В OnShow главной главной формы пытаюсь загрузить из файла настроек и применить тему (на скрине, как долж...
Ed Doc
13
Такс, блин, таки кто-то знает, каким образом работают макросы stdin/stdout/stderr? Я влез в stdio.h, там определения нет, отладил через асмокод - вызывается функция со странны...
The Bird of Hermes
18
Hi guys, I've been travelling and haven't been able to keep up to date. Do I have to do anything with my NOIA tokens since the rebranding, or was it just a name change?
Value Investor
9
Карта сайта