C struct inheritence
If you have no idea what “cursed” is, well, this is it.
As we all know, C not Objekt Orientiert is. tbh, I don’t like inheritence at all. But perhaps when maintaining some old codebase, you want to expand a struct without messing with the existing definitions.
Cursed but works
The old struct
|
|
Now extend it into a new struct: Make sure the base struct is the first member of extended struct, so that you can cast them into each other…
|
|
and you can safely(?) cast them:
|
|
[+] click to leave a comment [+]
the comment system on this blog works via email. The button below will generate a mailto: link based on this page's url and invoke your email client - please edit the comment there! [optional] even better, encrypt the email with my public key - don't modify the subject field - specify a nickname, otherwise your comment will be shown as anonymous - your email address will not be disclosed - you agree that the comment is to be made public. - to take down a comment, send the request via email.>> SEND COMMENT <<