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
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.

>[...]

-- 
Jonathan Leffler                         #include <disclaimer.h>
STSM, IBM Data Management Solutions.      Phone: +1 650-926-6921
Email: [EMAIL PROTECTED], [EMAIL PROTECTED]
Guardian of DBD::Informix v1.00.PC1 -- http://dbi.perl.org
     "I don't suffer from insanity; I enjoy every minute of it!"

Reply via email to