struct* mention before declaration/definition

Matt S Wartell msw at unix.cis.pitt.edu
Sat Jun 22 00:40:54 AEST 1991


I was porting some code to a PC under Turbo C++ 1.0 and encountered
some wierdness.  Turbo C claims to be ANSI conformant, so I wanted
to know if this is proper behavior.

The code I am porting has its header files out of order, so one of the
source files pre-processes into:

	/* declaration of function */
	void add_version(int a, struct B *b);

	/* definition of structure */
	struct B {
		...
	};

	/* definition of function */
	void add_version(int a, struct B *b)
	{
		...
	}

When the compiler gets to the function definition, it complains of a type
mismatch in parameter b.  It is our impression that the compiler should
produce an error at the function _declaration_ because the declaration
uses an undefined, undeclared type.

Does anyone know why the compiler did this, and whether or not it should
have?

Thanks in advance.
-- 
matt wartell, university of pittsburgh             msw at unix.cis.pitt.edu



More information about the Comp.std.c mailing list