RAD Studio
ContentsIndex
PreviousUpNext
W8015: Declare 'type' prior to use in prototype

(Command-line option to suppress warning: -w-dpu) 

When a function prototype refers to a structure type that has not previously been declared, the declaration inside the prototype is not the same as a declaration outside the prototype. 

For example,

int func(struct s *ps);  struct s  /* ... */ ;

Because there is no "struct s" in scope at the prototype for func, the type of parameter ps is pointer to undefined struct s, and is not the same as the "struct s" that is later declared. 

This will result in later warning and error messages about incompatible types, which would be very mysterious without this warning message. 

To fix the problem, you can move the declaration for "struct s" ahead of any prototype that references it, or add the incomplete type declaration "struct s;" ahead of any prototype that references "structs". 

If the function parameter is a struct, rather than a pointer to struct, the incomplete declaration is not sufficient. 

You must then place the struct declaration ahead of the prototype.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!