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.
11
questions
18
votes
5
answers
3k
views
Are int main() and int main(void) equivalent prototypes in C23?
C23 introduced new semantics in function declarators:
6.7.6.3 Function declarators
[...]
13 For a function declarator without a parameter type list: the effect is as if it were declared with a ...
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 ...
10
votes
2
answers
827
views
What are the [[reproducible]] and [[unsequenced]] attributes in C23, and when should I use them?
C23 introduced the attributes [[reproducible]] and [[unsequenced]].
What is the motivation behind them?
How are they defined, and what effect do they have on a function?
What kind of functions should ...
9
votes
3
answers
1k
views
How can I use "nullptr" for null pointers prior to C23?
In C23, the nullptr keyword got standardized. I would prefer to use nullptr instead of NULL prior to C23 too because it means that I could write code which compiles in:
C, prior to C23
C, since C23
C+...
7
votes
1
answer
200
views
Why doesn't gcc 13 display the correct binary represenation?
While answering a question here, I made the following example:
#include <stdio.h>
#include <math.h>
int main (void)
{
float_t a = -248.75;
printf("%f\n", a);
unsigned ...
4
votes
1
answer
125
views
What is the new QChar* in C23?
cppreference shows these prototypes for strchr():
char *strchr( const char *str, int ch ); (1)
/*QChar*/ *strchr( /*QChar*/ *str, int ch ); (2) (since C23)
and offers this explanation for the ...
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 ...
2
votes
0
answers
98
views
Why are there sequence point guarantees for C library functions?
I am looking at the C23 draft standard, but I think this would apply in C11 as well. There are several guarantees about sequence points in relation to function calls in C, such as before the return of ...
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 ...
2
votes
2
answers
1k
views
Is there a char8_t in C?
I have searched in many sites and did not get anything. I know that char8_t is a keyword in C++ since C++20. I am trying to find out in C, are they typedef-ing unsigned char to char8_t in C23 (with ...
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 ...