On Fri, 11 Jan 2002, 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").
We *could* put 't' beforehand: t_Foobar I am working on another project in which we do that and it works out nicely. > Personally, I use: typedef struct Abcdef { ... } Abcdef; That is, the > structure tag and the typedef name are the same. Even better if you do this: typedef struct Foo Foo; struct Foo { ... }; Then you can put 'Foo's inside of your struct and not have to put 'struct' in front of them. :-) > Is there any reason to keep structure tag names different from the > typedef name? What is the benefit? I don't think there is any. Every C compiler I've ever used lets you have the names be the same. > In practice, IMO, once the typedef 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 think if you need to use a struct before it is defined, then pre-declare it, otherwise some compilers will give warnings. - D <[EMAIL PROTECTED]>