On Fri, Jan 11, 2002 at 11:45:03AM -0800, Jonathan Leffler wrote:
> On Thu, 10 Jan 2002, Steve Fink wrote:
> 
> >[...]  I'd like to propose a convention [...]  By example:
> >
> >struct somename_t { ... };
> >typedef struct somename_t { ... }* Somename;
> >
> >The non-typedef'd name of a struct type ends in _t.
> 
> Is this a good idea?  The _t suffix is reserved by POSIX for use by the
> implementation (POSIX 1003.1-1996, Section 2.7.2, table 2-2, p43: "any
> POSIX.1 header included - key 1 - reserved suffix '_t'", and key 1 is
> "Prefixes and suffixes of symbols that shall not be declared or #defined
> by the application").
> 
> I know it has bitten Informix a couple of times (loc_t, dec_t).  In
> practice, most of the time, you will get away with it, but is 'most of
> the time' adequately portable for Parrot?  If you also apply a
> Parrot-specific prefix, then you can decide that trumps the banned
> suffix, but that is nasty.
> 
> Personally, I use: typedef struct Abcdef { ... } Abcdef; That is, the
> structure tag and the typedef name are the same -- I'm not pontificating
> on letter case but I do use leading capitals on type names in general.
> 
> Is there any reason to keep structure tag names different from the
> typedef name?  What is the benefit?  In practice, IMO, once the typedef

The reason I use a different name is because for ADTs I like to
typedef a pointer to a struct, and I definitely don't want 'struct
Stack' to be different from 'Stack'. But you're right, if we don't
typedef pointers as appears to be the prevailing opinion, there's no
reason to use a different name.

> is in place, the 'struct Tag' notation shouldn't be used thereafter; the
> only benefit to it is that you can write 'struct Tag *' where there is
> no previous declaration for 'struct Tag', which is at least nominally
> dubious coding practice - though it matches C++ forward declarations, so
> it is bearable.

I tend to use 'struct foo;' forward declaration quite a bit in C code
header files. It's good for disentangling a lot of fake
interdependencies among .h files.

Reply via email to