What is Nostr?
mos_8502 :verified: /
npub1qnu…hzwk
2024-04-13 00:33:07

mos_8502 :verified: on Nostr: Stupid C Tricks: Here's a fun one. Check out this snippet:<code>#pragma ...

Stupid C Tricks:

Here's a fun one. Check out this snippet:<code>#pragma once<br><br>__attribute__((transparent_union))<br>typedef union {<br> Widget widget_value;<br> DrawingArea drawing_area_value;<br> Label label_value;<br>} AnyWidget;<br></code>

See that attribute, "transparent_union"? That means a couple of things, but most importantly, it means that a function argument which is declared as that union type can take an argument value of any of the types in the union without casting; the local variable in the function will be of the union type.
Author Public Key
npub1qnufz4pycufk27kkeev5g0fgm0w0tqexsly674s2uwy0tynk5ymsk5hzwk