4 ms·
>Use typedef? What if you're given somebody else's code and you need to understand it to put a typedef there
by sebstefan 2y ago
>Use typedef?
What if you're given somebody else's code and you need to understand it to put a typedef there
- DaiPlusPlus 2y agoWelp, if it’s that bad then shrug and use a #define (Yes, this is a joke)
- CuriousCosmic 2y agoThe trick is to just assert equal types. Most compilers have extensions that allow you to easily compare type equality (and C23 actually standardizes the `typeof()` operator). So you basically take your ugly type, put it in a #define and then create a static assertion that matches the type against said ugly type. Now the compiler will throw a shit fit if the types don't match. Have fun breaking the type up into smaller pieces until you have something legible.