3 ms·
Eh, this misconception again.
by pwdisswordfishz 2y ago
Eh, this misconception again.
- userbinator 2y agoOver 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.google.com/+gregkroahhartman/posts/1ZhdNwbjcYF https://web.archive.org/web/20141218085356/https://plus.goog...
- ykonstant 2y agoIn 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?
- gregkh 2y agoThey 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.
- pwdisswordfishz 2y agoThat's not a reason not to use typedefs at all.
- casenmgreen 2y agoTypedefs 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.