Undefined structures

Jim Beveridge jim at newmedia.UUCP
Tue Feb 5 03:52:10 AEST 1991


Microsoft C compiles the following program with no errors:

	extern int callvw(struct _vw_package *pack);

	main()
		{
		}

I find this rather amazing considering that "struct _vw_package"
is undefined.

If I compile the program with gcc 1.37 under SunOS, I get this error:

t.c:1: warning: `struct _vw_package' declared inside parameter list
t.c:1: warning: its scope is only this definition or declaration,
t.c:1: warning: which is probably not what you want.

This would seem to imply that MSC v6 _might_ be doing the right thing
by defining the structure for just inside the prototype.

If I make the declaration, "struct junk *g;"  after the extern
above,  it compiles correctly even though "struct junk" doesn't
exist.

What exactly is going on here:

	What is the scope of these declarations?
	How are these references being resolved?
	What is proper compiler behavior?

		Thanks,
		 Jim



More information about the Comp.lang.c mailing list