This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Converting tm.h macros to functions




--On Monday, June 18, 2001 05:15:13 PM +0100 "Joseph S. Myers" 
<jsm28@cam.ac.uk> wrote:

> On Mon, 18 Jun 2001, Mark Mitchell wrote:
>
>>   struct target_t target = TARGET_INITIALIZER;
>
> Another question: what should this type be called?  POSIX reserves *_t, so
> something like "struct gcc_target" might be preferable.

Yes, this is a long-standing problem in GCC-land.

POSIX should never have reserved all names ending with _t, and in
practice OS vendors don't dare add more of these because
so many people use them in their code.  So, really, this is a prohibition 
against off_t, time_t, etc.  However, you're right that all such
identifiers are indeed reserved.

So, GCC has always just named types without any convention at all.
This is bad becuase a) you can't tell what's a type, and b) it tends
to make you want to do the `struct stat' hack:

  struct obstack obstack;

for example.  It's really natural to call your obstack `obstack', but
this is a confusing declaration.

One nice convention I've seen is to name all types `a_foo' or `an_foo'.
Then, you have:

  an_obstack obstack;

which is as clear as:

  obstack_t obstack;

but avoids the POSIX issue.

Some places in GCC to `struct foo_s' to encode the `struct'-ness --
which isn't really general, since sometimes you want this for
typedefs.

This will immediately become a flamewar.  If it were me, I would
subversively ignore it, and just do `a_target'.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]