3 ms·
If C23 is why not use constexpr? https://en.cppreference.com/w/c/language/constexpr https://en.cppreference.com/w/c/language/constexpr
by Y_Y 2y ago
If C23 is why not use constexpr?
https://en.cppreference.com/w/c/language/constexpr https://en.cppreference.com/w/c/language/constexpr
- lpribis 2y agoThis is not for declaring constexpr variables, it is about how to implement a checker function that verifies an inline expression is constant. Plus some of the examples work back to C99 instead of C23, which I would wager close to zero people are using in real-world code bases.
- cmptrnerd6 2y agoYou'd probably still win the wager but I do want to say there are some of us using C23. We even use it in our embedded systems running on arm based microcontrollers. Though we still do maintain some C89 code :(
- pantalaimon 2y agoC23 on embedded ARM is entirely painless as it’s all upstream GCC these days anyway. The problem is if you want to also still support esp8266 which is forever stuck at GCC 8.4
- Y_Y 2y ago#define C(x) ((constexpr typeof(x)){ (x) })
- Aardwolf 2y agoThe article mentions C23, but what they're trying to do is detect if something (possibly declared by someone else?) is a compile time constant, not to declare it as such