[krbdev.mit.edu #4057] GSSAPI opaque types should be pointers to opaque structs, not void*

Nicolas Williams Nicolas.Williams at sun.com
Wed Jul 26 10:33:31 EDT 2006


On Wed, Jul 26, 2006 at 03:25:11AM -0400, Marcus Watts wrote:
> Nicolas Williams <Nicolas.Williams at sun.com> writes:
> ...
> > You may not want to declare the partial structs.
> > 
> > The difference between this:
> > 
> > struct gss_name_struct;
> > typedef struct gss_name_struct * gss_name_t;
> > 
> > and this:
> > 
> > typedef struct gss_name_struct * gss_name_t;
> > 
> > is that with the former you can't provide an actual definition for
> > gss_name_struct in libgss, but with the latter you can.  This in turn
> > saves the need for automatic variables and casting.
> > 
> > I know.  Sun did the former.  But we might fix that...
> 
> Are you saying this shouldn't work:
> 	/* x.c */
> 	struct gss_name_struct;
> 	typedef struct gss_name_struct * gss_name_t;
> 
> 	struct gss_name_struct {
> 		int x;
> 		char *y;
> 	} foo[1];
> 
> and if so, what compiler???

No.  This should work:

	/* x.c */
	typedef struct gss_name_struct * gss_name_t;

	struct gss_name_struct {
		int x;
		char *y;
	};

See the difference?

> As far as I know, the two forms you gave above should be completely
> interchangeable.  The 2nd form you gave should[*] have exactly the same
> effect on the compiler as the first form except for being slightly shorter.
> 	[*] "imho", or assumes sane C compiler & standard(s)

The first form precludes defining the structure contents; try it, you
should get an error about multiple definitions of gss_name_struct.  The
second form simply declares a pointer type that is different from all
other pointer types.

Nico
-- 



More information about the krbdev mailing list