Re:C "clockwise/spiral" rule to understand declarations
by casenmgreen on Wednesday January 01, 2025 @06:04AM
(#42565327)
Typedefs are useful only if you use functions for all operations on the data type.
Otherwise, if you actually use the variable directly, you are requiring the user to remember the underlying type of the typedef.
Larger program, hundred plus typedefs, unbearable burden on reader.
Re:C "clockwise/spiral" rule to understand declarations
by gregkh on Wednesday January 01, 2025 @05:32AM
(#42565182)
They hide structures very easily, allowing programmers to accidentally put them on the stack or use them as parameters in functions where they shouldn't be doing so. By forcing "struct" on the name, it makes it more obvious as to what you are doing.
Re:C "clockwise/spiral" rule to understand declarations
by pwdisswordfishz on Wednesday January 01, 2025 @05:36AM
(#42565201)
That's not a reason not to use typedefs at all.
> Heh, no, typedefs don't help anything, there's a reason we don't use them in the Linux kernel whenever possible.
This surprises me, can someone explain that remark and elaborate on the reason it alludes to?