DragonFly BSD
DragonFly submit List (threaded) for 2004-02
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: patch to style(9) man page to reflect current practices


From: Joerg Sonnenberger <joerg@xxxxxxxxxxxxxxxxx>
Date: Thu, 5 Feb 2004 19:16:23 +0100

On Thu, Feb 05, 2004 at 09:50:56AM -0800, Matthew Dillon wrote:
>     If structname_t represents a pointer, you can typedef it without
>     having to include the header containing the actual structure.
> 
>     e.g.
>     header1.h:
> 
>     struct fubar;
>     typedef struct fubar *fubar_t;
> 
>     header2.h:
> 
>     struct fubar {
> 	....
>     };
> 
>     header1 does not require header2.

Right. But this kind of behaviour is exactly what I would discourage.
It is IMHO ok, if the typedef is in header2.h, but otherwise we have
some really bogus kind of dependency. There are very few examples
in src/sys/sys for this behaviour.

sys/thread.h defines thread_t as forward define which is fine.

sys/types.h defines dev_t as struct specinfo*, which is fine too,
since sys/types.h is the first include and things defined there are
somewhat special anyway.

sys/tprintf.h defines tpr_t as struct session*, which is IMO unnecessary.

Many headers define a struct name and the corresponding name_t in the
same line. Esp. those which are widely used.

Basically I think discouraging the _t typedef is OK, since it should be
carefully evaluated wether it is really useful to hide wether a given
type is a structure or a pointer to such a structure for any arbitrary
type name.

Joerg

> 						-Matt



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]