4 ms·
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
by ykonstant 2y ago
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?
- 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.