Re:C "clockwise/spiral" rule to understand declarations
by pwdisswordfishz on Wednesday January 01, 2025 @04:52AM
(#42565038)
Eh, this misconception again.
[ Parent
| on HN ]
Re:C "clockwise/spiral" rule to understand declarations
by userbinator on Wednesday January 01, 2025 @04:58AM
(#42565055)
Over 30 years and it still won't die.
Sadly the link to Linus Torvalds' explanation of why it doesn't work has died, but the Archive remembers:
https://web.archive.org/web/20141218085356/https://plus.goog...
Re:C "clockwise/spiral" rule to understand declarations
by ykonstant on Wednesday January 01, 2025 @05:27AM
(#42565159)
In that thread, replying to a suggestion to use typedefs, Kroah-Hartman states:
> 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?
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.