C23: A Slightly Better C

C23: A Slightly Better C

One of the established and most popular programming languages is the C programming language. It is relatively easy to learn, and highly practical.

Maybe surprisingly, the C programming language keeps evolving, slowly and carefully. If you have GCC 23 or LLVM (Clang) 16, you already have a compiler with some of the features from the latest standard (C23).

// Only include stdio.h if it exists
#if __has_include ()
#include
#endif

#include

[[deprecated]]
void f() {}

[[nodiscard]]
int g(int x) {
return x + 1;
}

int main() {
f(); // compile-time warning: ‘f’ is deprecated
g(1); // compile-time warning
auto x=0b1111;
typeof(x) y=1’000’000; // type of y is the same as x
printf(“%dn”, x); // prints 15
printf(“%dn”, y); // prints 1000000
constexpr int N=10;
// compile-time asserts using static_assert
static_assert (N==10, “N must be 10”);
bool a[N]; // array of N booleans
for (int i=0; i
>>> Read full article>>>
Copyright for syndicated content belongs to the linked Source : Hacker News – https://lemire.me/blog/2024/01/21/c23-a-slightly-better-c/

Exit mobile version