L
Laurent Deniau
I would like to know why the following small program does not compile
(checked with gcc 4.1.2) and if the compiler behavior is correct:
typedef void (T)(struct A*);
void f(void) {
struct A { int _; } a;
((T*)0)(&a);
}
../chk.c:8: warning: passing argument 1 of '0u' from incompatible
pointer type
If the declaration of a is moved just outside the definition of f,
everything is right. It seems that the forward struct A declaration
doesn't refer to the definition if it occurs inside f, but does if it
occurs outside f (say same scope level)? References to C99 are
welcome.
The aim would be to have a 'generic' (global) function type
declaration specialized case by case locally. Any clue to achieve
this? My feeling is that it is not possible since it breaks the nested
scopes encapsulation and C doesn't like it.
a+, ld.
(checked with gcc 4.1.2) and if the compiler behavior is correct:
struct A;cat ./chk.c
typedef void (T)(struct A*);
void f(void) {
struct A { int _; } a;
((T*)0)(&a);
}
../chk.c: In function 'f':gcc -std=c99 -pedantic -Wall -W -c ./chk.c
../chk.c:8: warning: passing argument 1 of '0u' from incompatible
pointer type
If the declaration of a is moved just outside the definition of f,
everything is right. It seems that the forward struct A declaration
doesn't refer to the definition if it occurs inside f, but does if it
occurs outside f (say same scope level)? References to C99 are
welcome.
The aim would be to have a 'generic' (global) function type
declaration specialized case by case locally. Any clue to achieve
this? My feeling is that it is not possible since it breaks the nested
scopes encapsulation and C doesn't like it.
a+, ld.