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
16 votes
0 answers
279 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
  • 207k
4 votes
0 answers
92 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
  • 207k
1 vote
0 answers
64 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,170
1 vote
1 answer
111 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
133 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,170
1 vote
1 answer
61 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,170
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,170
2 votes
1 answer
89 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,170
3 votes
1 answer
81 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,170
2 votes
2 answers
138 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,170
3 votes
3 answers
146 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,170
2 votes
0 answers
97 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
113 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,170
0 votes
0 answers
46 views

Restrictions on auto keyword for type inference in C2X

int main() { auto status = 203; auto static const str = "Hello"; auto static const strs = {"Hello", "World"}; return status; } From playing around with ...
Harith's user avatar
  • 7,170
3 votes
1 answer
53 views

What's an implementation required to do upon seeing unknown attributes?

C2X has introduced "Attribute specifier sequence", which can be of these forms: 1) standard attribute, such as [[fallthrough]] 2) attribute with a namespace, such as [[gnu::unused]] 3) ...
Harith's user avatar
  • 7,170

15 30 50 per page
1
2 3 4 5