On Mon, 2009-06-01 at 20:19 -0700, Rick Altherr wrote:
> On Jun 1, 2009, at 8:08 PM, Zach Welch wrote:
> 
> > On Mon, 2009-06-01 at 11:12 -0700, Rick Altherr wrote:
> >> I'm all for removing the type redundancy, but I'd rather see the
> >> typedef stay and remove the struct name instead. It reduces typing
> >> when specifying the type and gets rid of the unnecessary separation  
> >> of
> >> struct type names from other types.
> >
> > You are suggesting that we make all struct types anonymous, relying
> > exclusively on typedefs?
> >
> > As far as I can tell, this simply would not work, because it would  
> > force
> > headers to include the definition of those struct types in order to  
> > use
> > them in any capacity.  One could no longer do:
> >
> > struct foo;
> > typedef struct foo foo_t;
> >
> > In other words, one could no longer create forward references at all,
> > because there would be nothing to name as the type. This plan seems  
> > like
> > it would lead us back to circular header dependencies.
> >
> > Cheers,
> >
> > Zach
> >
> 
> 
> Actually, I was suggesting using the typedef to be an opaque handle.   
> The comments you grabbed were a precursor of sorts and as you  
> correctly point out, do not allow forward declaration at all.   
> Instead, I meant something like:
> 
> struct foo;
> typedef struct foo * foo_t;
> 
> Then, the API would use foo_t's as arguments.  The fact that is a  
> pointer to a struct is an implementation detail.  To the user of the  
> API, it's a foo regardless of how it is implemented.

Thank goodness!  We have almost arrived on the same page; I am with you
on these dieas, except I would suggest '_p' for such types. :)

I have some other clean up in mind that should be done before we try to
tackle this stuff, but I will revise my C style guide patch with the
ideas in this thread and repost them soon.

Cheers,

Zach
_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to