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.

3 votes
2 answers
131 views

Using _Generic to implement IS_POINTER(p) with rvalue in C23?

I want to implement IS_POINTER(P) using _Generic. Using this answer that implements IS_ARRAY(A) as a starting point, I have: #define IS_POINTER(P) \ _Generic( &(P), \ typeof(*P) ** : ...
Paul J. Lucas's user avatar
0 votes
5 answers
153 views

Can C23 endianness macros be used to determine the layout of a bit-field?

I've been reading about the new additions to the C standard, and I've come across macros for determining the compile-time endianness. However the standard still states that The order of allocation of ...
zorleone's user avatar
2 votes
2 answers
184 views

Plain C equivalent to Rust's unimplemented!() macros

Please note that this is not a question on C++, but on plain C In Rust there is a handy macro unimplemented!() to let the runtime crash, to be used when a function is unimplemented. I basically have ...
wirrbel's user avatar
  • 3,261
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 ...
chqrlie's user avatar
  • 142k
3 votes
2 answers
630 views

Is the C23 standard backward compatible?

Can C17 code be interpreted as C23 code? If not, what are the breaking changes?
DarkFranX's user avatar
  • 500
2 votes
0 answers
1k views

Is there any difference between the C23 _BitInt() and a non-bit-precise integer of the same width?

The upcoming C23 Standard adds a keyword _BitInt() which can be used, as I understand, to define an integer with a specific number of bits. However I could not find much information with regards to ...
CPlus's user avatar
  • 4,378
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 ...
Lundin's user avatar
  • 208k
4 votes
1 answer
143 views

does offsetof work with typeof if type is new?

I read on cppreference (https://en.cppreference.com/w/c/types/offsetof): Even though it is specified in C23 that defining a new type in offsetof is undefined behavior, such usage is only partially ...
Abdulmalek Almkainzi's user avatar
5 votes
5 answers
272 views

How to use typeof_unqual to avoid compiler warnings about discarding const qualifier

In the following code, copyThing() is written so that its return value has the same type as its argument value: extern void *copyThingImpl(const void *x); #define copyThing(x) ((typeof(x)) ...
Peter Eisentraut's user avatar
10 votes
2 answers
280 views

Does nullptr_t break type punning or pointer conversions?

Consider this union: typedef union { void* vptr; nullptr_t nptr; } pun_intended; nullptr_t is supposedly compatible with void* 1). Ok so what if we initialize the void* to some non-zero ...
Lundin's user avatar
  • 208k
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+...
Jan Schultke's user avatar
  • 36.1k
3 votes
2 answers
310 views

Is there an equivalent of __attribute__((nonnull)) in C23?

Several compiler vendors have implemented a non standard extension __attribute__((nonnull)) to specify that a pointer must not be a null pointer. C99 introduced a new syntax to specify that a function ...
chqrlie's user avatar
  • 142k
3 votes
1 answer
242 views

Can strlen be [[unsequenced]]?

The wording of the C23 working draft on unsequenced functions is unclear to me. Among other properties, unsequenced functions have to be independent: (6) An object X is observed by a function call (...
Jan Schultke's user avatar
  • 36.1k
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 ...
Jan Schultke's user avatar
  • 36.1k
3 votes
3 answers
310 views

What is the difference between C++11's constexpr and C23's [[reproducible]]?

C++11 added the constexpr keyword which can be added to functions to specify constant behavior. C23 added what seems to be identical functionality in the form of the [[reproducible]] tag. How are ...
Badasahog's user avatar
  • 659

15 30 50 per page