J
j0mbolar
What is the chapter and verse for the following?
#include <stdio.h>
void foo(struct bar *baz);
struct bar {
int x, y;
};
int main(void)
{
return 0;
}
Which, with gcc, yields:
dec.c:3: warning: `struct bar' declared inside parameter list
dec.c:3: warning: its scope is only this definition or declaration,
which is probably not what you want.
Is it just me or is this compiler stupid?
Where is struct bar declared inside the parameter list?
It would make sense if it was instead:
void foo(struct bar { int x, y; } * baz);
or something equally insane but this isn't the case.
the type definition follows /after/ the prototype
and additionally we can have pointers to
incomplete types. So this is a case of gcc
issuing an incorrect diagnostic, yes?
#include <stdio.h>
void foo(struct bar *baz);
struct bar {
int x, y;
};
int main(void)
{
return 0;
}
Which, with gcc, yields:
dec.c:3: warning: `struct bar' declared inside parameter list
dec.c:3: warning: its scope is only this definition or declaration,
which is probably not what you want.
Is it just me or is this compiler stupid?
Where is struct bar declared inside the parameter list?
It would make sense if it was instead:
void foo(struct bar { int x, y; } * baz);
or something equally insane but this isn't the case.
the type definition follows /after/ the prototype
and additionally we can have pointers to
incomplete types. So this is a case of gcc
issuing an incorrect diagnostic, yes?