tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: [PATCH] style(5): No struct typedefs
On Tue, Jul 11, 2023 at 05:56:27 -0700, Jason Thorpe wrote:
> > On Jul 11, 2023, at 3:17 AM, Taylor R Campbell <riastradh%NetBSD.org@localhost> wrote:
> >
> > If we used `struct bus_dma_tag *' instead, the forward declaration
> > could be `struct bus_dma_tag;' instead of having to pull in all of
> > sys/bus.h, _and_ the C compiler would actually check types.
>
> In the original design, it's not always a struct. That was the
> whole point of using a more abstract type.
The bus_dma_tag_t example from the original email is not the best one,
but I didn't want to open that can of worms in my reply, so I
mentioned the "not always struct" case without actually mentioning
names.
The style(5) specifically gives an example of a struct typedef, not of
an opaque typedef.
> If you want to hide the struct'ness in a machdep header file, fine,
> but I completely disagree with the notion of requiring the use of
> the "struct" keyword all over the place.
I used to lean both ways at different times and in different contexts.
I think that existence and usefulness of opaque typedefs is exactly
the strong argument against using "convenience struct typedefs", b/c
the latter dilute the message so to speak. If someone wants to
program with "systems hungarian", they know where to find it...
-uwe
Home |
Main Index |
Thread Index |
Old Index