Skip to main content

Questions tagged [c23]

C23 is the informal name of the next standard of the C programming language. It replaces C17 and introduces some new features.

5 votes
1 answer
1k views

What is the difference between float, _Float32, _Float32x, and _Float32_t?

C23 introduced a number of floating point types, including but not limited to: _Float32 _Float32x _Float32_t I am unsure of the differences, such as: Are they keywords, or are they type aliases, or ...
Jan Schultke's user avatar
  • 36.1k
3 votes
1 answer
187 views

What is the alignment requirement of malloc(1)

I have heard that a successful call to malloc() returns a pointer suitably aligned for any type. Yet it seems useless and wasteful to require malloc(1) to return a pointer aligned for a larger value ...
chqrlie's user avatar
  • 142k
0 votes
1 answer
85 views

How to avoid mentioning a function pointer's arguments inside the definition of a function that takes it as argument?

I'm writing this C code that involves passing around a lot of function pointers, and sometimes writing all the arguments that a function pointer takes when defining a function that takes it as an ...
Mehdi Charife's user avatar
2 votes
1 answer
269 views

What Exactly is the Proposed C23 `_Either` Type?

C23 proposal n3003 and n2366 mention a proposed _Either type in passing on the first page and seventh, respectively, and I have not been able to find any other references to it thus far. As far as I ...
William Ryman's user avatar
11 votes
3 answers
2k views

C23 auto vs C++11 auto

The C23 standard apparently has introduced using "auto" keyword for auto type deduction, see here, just like in C++11. However, there seems to be some differences. According to here, https://...
Mr User's user avatar
  • 245
2 votes
2 answers
2k views

gcc: constexpr functions in C23?

Playing around with constexpr with GCC v14.0 (which should be close to the soon to be released GCC v13.1), I compiled the following module: constexpr int f (int x) { return x + 2; } constexpr ...
emacs drives me nuts's user avatar
0 votes
2 answers
474 views

Regarding mainstream compilers and int main(){} in C23

My program: int main(){} In upcoming C23, non-prototype and "K&R style" functions are removed. I realize that C23 is not yet formally released, but the current behavior of gcc and clang ...
Lundin's user avatar
  • 208k
3 votes
2 answers
243 views

Initialize block-scope static const variable with pointer to compound literal?

The following code is rejected by GCC and Clang (godbolt link): struct thing; typedef enum { THING_TYPE_A, THING_TYPE_B, } thing_type_t; typedef struct thing_a { int i; } thing_a_t; typedef ...
Charles Nicholson's user avatar
6 votes
1 answer
268 views

Why does the C23 standard decrease the max size of an object the implementation must support?

I'm currently reading the new draft of the C23 standard (N3088), and I've noticed that in §5.2.4.1 the standard states: The implementation shall be able to translate and execute a program that uses ...
meniadin's user avatar
12 votes
1 answer
8k views

What is the purpose of the new C23 #embed directive?

A new preprocessor directive is available in the upcoming C23 Standard: #embed Here is a simple example: // Placing a small image resource. #include <stddef.h> void show_icon(const unsigned ...
chqrlie's user avatar
  • 142k
0 votes
0 answers
99 views

why weak attribute has not been selected for C23?

I can see that there is a new keyword type 'attributes' in C23. Some of it, like [[deprecated]] were used in C11+GNU __attribute__((deprecated)). I looks like a great update. I wonder why a usefull ...
Guillaume D's user avatar
  • 2,288
4 votes
2 answers
453 views

Why is strnlen() not considered for inclusion in C23?

Functions strdup() and strndup() have finally made it into the upcoming C23 Standard: 7.24.6.4 The strdup function Synopsis #include <string.h> char *strdup(const char *s); The strdup function ...
chqrlie's user avatar
  • 142k
3 votes
1 answer
1k views

Looking for stdckdint.h in the gcc 11.2 collection

I'm trying to find a copy of stdckdint.h, which I assume should be in the gcc 11.2 collection, but a search fails to locate it in the downloaded source tarball. Is it not public yet, or do I have to ...
Ian's user avatar
  • 1,657
1 vote
1 answer
103 views

Two types have compatible type if their types are the same: confused

C2x (N2596), 6.2.7 Compatible type and composite type, 1: Two types have compatible type if their types are the same. The grammar of that sentence is confusing. For example: How type can have a ...
pmor's user avatar
  • 5,941
2 votes
1 answer
350 views

Implementing std::bit_cast equivalent in C

Is it possible to implement something similar to C++20's std::bit_cast in C? It would be a lot more convenient than using union or casting pointers to different types and dereferencing. If you had a ...
Jan Schultke's user avatar
  • 36.1k

15 30 50 per page