3 ms·
I first read about the style of not typedef'ing structs in the Linux Kernel style guidelines. I read some of the justifications and the pointer issue you also b
by dottrap 7y ago
I first read about the style of not typedef'ing structs in the Linux Kernel style guidelines. I read some of the justifications and the pointer issue you also bring up is a really convincing one. But I was also convinced by the context argument. I've seen Linus use this one to talk about the downsides of using C++, but it also applies here. Basically, when reviewing a small block of code, it is typically possible to understand what the code does in C (whereas in C++, because of all the language features that kick in automatic implicit behaviors, it is much harder to know if any of that is going on without much more context.) Similarly with the explicitness of struct, you know exactly what is going on and you don't have the ambiguity of whether the type is a struct, pointer, or primitive type (like int) and how they impact the behavior slightly differently in the language.