Damus
David Chisnall (*Now with 50% more sarcasm!*) · 7w
Any #GCC folks know why the transparent_union attribute works in C but not C++? The motivating use case is for a system header, which exposes an API that needs to be callable from both C and C++ with...
Andrea (Drea) Tamar Pinski profile picture
@nprofile1q...

transparent_union was only originally for wait.
Since in c++ you can have overloads based on the argument, you dont need say int* or union wait*, you could just pass union wait* and that would then cast to int* in the overload and pass to the extern"C" function.

The other thing is the c++ front end just never got the support for it because of the overloads could happen. Recently (In the last 20 years), the usage in glibc was removed so the support for transparent_union was much less needed so it just was never added to the c++ frontend.

Note in gcc, the c and c++ front end have different code to function call resolution (and differentparsers); this is different from clang. So in summary it just was not seen as needed and nobody hooked it up.
1
David Chisnall (*Now with 50% more sarcasm!*) · 7w
nostr:nprofile1qy2hwumn8ghj7un9d3shjtnyd968gmewwp6kyqpqkj309zdwj9epqml3h5v0ma8vrgelxqmx04aw2dl4xjudcu3mp4pqcuted5 Thanks (I thought you might know the answer!). It turns out unions in C++ are more like classes than I thought (I'd not really used them before today, I thought they were more like en...