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 Fri 2023-07-14 08:12, Jason Thorpe <thorpej%me.com@localhost> wrote:
> >
> > The typedef itself buys you nothing but a few charactes less to type,
>
> No, that’s not correct.  For a type that’s meant to be “opaque” (i.e. “users of the interface should not have to know or
> care about any of the implementation details, historical leakage be damned”), the typedef gives you true opacity…
> if you’re using “struct kmutex *” rather than “kmutex_t *” then you’re already eating the forbidden fruit.

Jason is right about this. 

I've had to change internal implementations in our code from "struct" to "union" at the top level. (This was because of a need to increase the level of abstraction in the implementation.)

That refactor had no impact on client code. Our code uses typedef style, and whatever its merits, the style allows refactoring of the implementation, provided that you separate the API header files from the implementation (and don't disclose the implementation for use by client source code).

--Terry



Home | Main Index | Thread Index | Old Index