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.

--
Rick Altherr
kc8...@kc8apf.net

"He said he hadn't had a byte in three days. I had a short, so I split it with him."
 -- Unsigned



Attachment: smime.p7s
Description: S/MIME cryptographic signature

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

Reply via email to