public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Bernard Dautrevaux <Dautrevaux@microprocess.com>
To: 'Nick Duffek' <nsd@redhat.com>,
	Bernard Dautrevaux <Dautrevaux@microprocess.com>
Cc: gdb@sources.redhat.com, insight@sources.redhat.com
Subject: RE: Register group proposal
Date: Mon, 26 Feb 2001 05:29:00 -0000	[thread overview]
Message-ID: <17B78BDF120BD411B70100500422FC6309E218@IIS000> (raw)

> -----Original Message-----
> From: Nick Duffek [ mailto:nsd@redhat.com ]
> Sent: Sunday, February 25, 2001 12:52 AM
> To: Dautrevaux@microprocess.com
> Cc: gdb@sources.redhat.com; insight@sources.redhat.com
> Subject: RE: Register group proposal
> 
> 
> On 23-Feb-2001, Bernard Dautrevaux wrote:
> 
> >Perhaps for avoiding an unneeded dependency, that would 
> trigger superfluous
> >recompiles of users of "abc.h" that do not need "xyz.h" if "xyz.h" is
> >modified?
> 
> I agree that's a pain.  But prohibiting typedefs only avoids a small
> subset of superfluous recompiles.  For example, changing a 
> single macro in
> gdbarch.h causes a massive rebuild.
> 
> Eventually, GCC probably will support header file compilation, which
> probably will lead to fully-accurate dependency generation.  This will
> eliminate superfluous recompiles.
> 
> In the meantime, the problem diminishes as hardware speedups 
> outpace GCC
> complexity.
> 
> However, humans won't ever get better at writing maintainable code or
> understanding existing code.  Typedefs help us achieve both of those
> goals.

I must say that, although it's a bit shorter, I don't see a real advantage
to define some interface type xxx for

(1) typedef struct { ... } xxx;
    void f(xxx*);

and 

(2) struct xxx;
    void f(struct xxx*);

If you want to get rid of the "struct" in the interface you can go a bit
further:

(3) #ifndef xxx_t
    #define xxx_t struct xxx
    #endif
    void f(xxx_t*);

You can even go even farther and eliminate the '*' from interfaces:

(4) #ifndef xxx_t_defined
    #define xxx_t_defined
    typedef struct xxx* xxx_t;
    #endif
    void f(xxx_t);

Personally, I always use approach (2) and never had any problem, but this
may be biased by the fact that most of my own code is written in C++, so the
typedef is implicit and (2) is roughly equivalent to (1), but with the
advantage that xxx is an opaque type, something IMNSHO greatly compensate
for the need to add the "struct" keyword in C.

Regards,

	Bernard

--------------------------------------------
Bernard Dautrevaux
Microprocess Ingenierie
97 bis, rue de Colombes
92400 COURBEVOIE
FRANCE
Tel:	+33 (0) 1 47 68 80 80
Fax:	+33 (0) 1 47 88 97 85
e-mail:	dautrevaux@microprocess.com
		b.dautrevaux@usa.net
-------------------------------------------- 

             reply	other threads:[~2001-02-26  5:29 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-26  5:29 Bernard Dautrevaux [this message]
2001-02-26  9:28 ` Christopher Faylor
2001-02-26 10:56   ` Andrew Cagney
2001-02-26 11:28     ` Christopher Faylor
2001-02-26 17:02       ` Andrew Cagney
2001-02-27  8:53         ` Christopher Faylor
2001-02-27  9:57           ` Andrew Cagney
  -- strict thread matches above, loose matches on Subject: below --
2001-02-28  1:59 Bernard Dautrevaux
2001-02-23  2:52 Bernard Dautrevaux
2001-02-24 15:43 ` Nick Duffek
2001-02-26 18:21   ` Andrew Cagney
2001-02-27 10:30     ` Jim Kleck
2001-02-27 11:24       ` Per Bothner
2001-02-27 13:44         ` Jim Kleck
2001-02-27 15:17           ` Andrew Cagney
2001-02-22  9:19 Michael Elizabeth Chastain
2001-02-21  3:00 Stephane Carrez
2001-02-21  7:00 ` Nick Duffek
2001-02-21  9:34 ` Andrew Cagney
2001-02-20 20:56 Nick Duffek
2001-02-21  6:44 ` Fernando Nasser
2001-02-21  7:10   ` Nick Duffek
2001-02-21  7:36     ` Fernando Nasser
2001-02-21  7:58     ` Keith Seitz
2001-02-21  8:50 ` Andrew Cagney
2001-02-21 11:43   ` Andrew Cagney
2001-02-25 15:36   ` Nick Duffek
2001-02-21 11:43 ` Andrew Cagney
2001-02-21 12:28   ` Andrew Cagney
2001-02-21 12:18 ` Andrew Cagney
2001-02-22  0:59   ` Eli Zaretskii
2001-02-22  4:29     ` Nick Duffek
2001-02-22  8:46       ` Andrew Cagney
2001-02-22  8:56         ` Keith Seitz
2001-02-22  9:20           ` Andrew Cagney
2001-02-22  5:17   ` Nick Duffek
2001-02-22  6:36     ` Fernando Nasser
2001-02-22  8:23       ` Andrew Cagney
2001-02-22  7:58     ` Andrew Cagney
2001-02-22  8:37       ` Nick Duffek
2001-02-22  9:12         ` Andrew Cagney
2001-02-22 10:15           ` Nick Duffek
2001-02-22 10:25             ` Andrew Cagney
2001-02-22 11:40               ` Eli Zaretskii
2001-02-22 11:02           ` Kevin Buettner
2001-02-22 12:08             ` Andrew Cagney
2001-02-22  8:16     ` Andrew Cagney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17B78BDF120BD411B70100500422FC6309E218@IIS000 \
    --to=dautrevaux@microprocess.com \
    --cc=gdb@sources.redhat.com \
    --cc=insight@sources.redhat.com \
    --cc=nsd@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).