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.

c23
2 votes
1 answer
59 views

Using previously set fields when initializing structure with compound literals

What is the expected behavior of referring to previously set fields, when declaring initial values for a struct using compound literal: Specifically is it ok to: struct foo v = { .v1 = ..., .v2 = .v1+...
dash-o's user avatar
  • 14.2k
1 vote
3 answers
137 views

In C language, are objects that are not explicitly initialized necessarily implicitly initialized?

The question I'm going to ask might be quite long. If possible, please read it through patiently. First of all, let's take a look at the content of §6.7.9 Initialization in C11: ¶8: An initializer ...
user24723440's user avatar
17 votes
0 answers
319 views

realloc(ptr, 0) in C23 - now what?

According to the change log of C23, proposal n2464 was voted-in and implemented, making realloc(ptr, 0) explicitly undefined behavior, whereas it was supposedly implementation-defined in previous ...
Lundin's user avatar
  • 208k
4 votes
0 answers
94 views

Is there such a thing as "function attribute correctness"?

Ok so C23 adds function attributes to the language but I'm not sure if anyone actually considered how they are supposed to be used. Consider this example: [[deprecated]] int foo () { return 0; } [[...
Lundin's user avatar
  • 208k
1 vote
0 answers
66 views

Semantics of functions taking a QChar * when passed a void * or const void *

This is a follow-up to: What is the new QChar* in C23?, where @Lundin showed a sample implementation of a function that takes a QChar * with _Generic, after which I implemented strchrnul() like so: #...
Harith's user avatar
  • 7,235
1 vote
1 answer
113 views

what's the problem of passing parameters to void function in c?

In the C programming language, when you want to declare a function without parameters, you write its signature like this: int foo(void); When you want to declare a function with unspecified ...
David's user avatar
  • 53
2 votes
1 answer
177 views

error: must specify at least one argument for '...' parameter of variadic macro

You can define a variadic macro in C like: #define F(x, ...) f(x, __VA_ARGS__) But calling F as F(a) results in the macro expansion f(a,) which would not compile. So C23 includes __VA_OPT__ to ...
Harith's user avatar
  • 7,235
1 vote
1 answer
62 views

Detecting _BitInt type in _Generic

From ISO/IEC 9899:2024, 6.2.5 Types: ... 5 A bit-precise signed integer type is designated as _BitInt(N) where N is an integer constant expression that specifies the number of bits that are used to ...
Harith's user avatar
  • 7,235
4 votes
1 answer
111 views

Check if array is a VLA at compile-time

@Lundin shows how to check if a passed expression is an array at compile-time here: Lvalue conversion of _Generic controlling expression involving array clang warning wrong?: #define IS_ARRAY(T) ...
Harith's user avatar
  • 7,235
2 votes
1 answer
90 views

Can the expanded code of an inline function differ between 2 translation units?

Say I have a macro UNIQUE_NAME(PREFIX) that concatenates __LINE__ to PREFIX: #define CONCAT2_EXPAND(a, b) a ## b #define CONCAT2(a, b) CONCAT2_EXPAND(a, b) #define UNIQUE_NAME(prefix) ...
Harith's user avatar
  • 7,235
3 votes
1 answer
82 views

How and why use call_once()?

From N3220, §7.28.2.1 “The call_once function”: Synopsis #include <threads.h> void call_once(once_flag *flag, void (*func)(void)); Description The call_once function uses the once_flag pointed ...
Harith's user avatar
  • 7,235
2 votes
2 answers
154 views

What is the __STDC_VERSION__ value for C23?

What is the STDC_VERSION value for C11? asks about C11, and How can I use "nullptr" for null pointers prior to C23? says that the current versions of GCC and Clang define it to a placeholder ...
Harith's user avatar
  • 7,235
3 votes
3 answers
150 views

What are source and execution character sets?

I was looking at the changes in C23, and found this in Annex M of the C23 draft: added @ (U+0040, COMMERCIAL AT), $ (U+0024, DOLLAR SIGN), and ` (U+0060, GRAVE ACCENT, "Backtick") into the ...
Harith's user avatar
  • 7,235
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 ...
Kyle's user avatar
  • 990
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 ...
Harith's user avatar
  • 7,235

15 30 50 per page
1
2 3 4 5