Register group proposal
Nick Duffek
nsd@redhat.com
Thu Feb 22 08:37:00 GMT 2001
On 22-Feb-2001, Andrew Cagney wrote:
>Have a look at ui-out.h, ui-file.h, gdbarch.h, ... They have all used
>``struct foo *'' to implement an opaque type. In all cases it isn't
>possible to get to the inner workings.
I've noticed, and I've spent time scratching my head over why structs are
used in various places.
>Regarding typedefs. Per my e-mail
> http://sources.redhat.com/ml/gdb-patches/2001-02/msg00325.html it
>encouraging a tangled web of includes.
The example you quoted in that email:
Try declaring something like:
xyz.h:
struct xyz;
exter void xyz_foo (struct xyz *self, ...);
abc.h:
struct xyz;
struct abc;
extern abc_on_xyz (struct abc *self, struct xyz *on);
using typedefs. It ends up creating include spaghetti :-(
is very easy to declare using typedefs. Here's abc.h:
#include "xyz.h"
typedef struct {
int i;
} Abc;
extern int abc_on_xyz (Abc *self, Xyz *on);
Here's xyz.h:
typedef struct {
int j;
} Xyz;
extern void xyz_foo (Xyz *self);
Do we have an official policy prohibiting typedefs in include files?
Nick
More information about the Gdb
mailing list