All Questions
3
questions
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 ...
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)) ...
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 ...