For this code:
void fun(struct A*);
void fun(struct A* p) {
}
I get with the CF compiler in CW for MCU 6.3 the following warnings:
Warning : types that are declared in parameter lists ('A') go out of scope at the end of the function declaration/definition,this is probably not what you want (maybe use a forward declaration?)main.c line 1 void fun(struct A*); Warning : types that are declared in parameter lists ('A') go out of scope at the end of the function declaration/definition,this is probably not what you want (maybe use a forward declaration?)main.c line 2 void fun(struct A* p) { Error : identifier 'fun(struct A *)' redeclared as '__regabi void (struct A *)'main.c line 2 void fun(struct A* p) { Error : identifier 'fun(struct A *)' was originally declared as '__regabi void (struct A *)'main.c line 1 void fun(struct A*);
Or in other words, the struct tag was first seen in a parameter declaration. As this is a local scope,
the compiler does not treat it as the same type as in the function definition even if it does have the same tag name.
In order to fix this, just declare the tag before using it in the declaration.
E.g.
struct A;void fun(struct A*);void fun(struct A* p) {}
Daniel
BTW: The title of this post is a bit misleading as this does not happen for basic types like char's only for user defined tags.