R
Ranga
Hello,
Can some one explain me the scope and life of a C struct. I saw a
piece of code that look like the following. My lint tool rejects the
code, but gcc accepts the code. I tried to play around with number and
type of the structure member list, still gcc accepts.
/* file f1.c */
int func_f1(void)
{
struct my_struct {
int a;
char *name;
int b;
} *list;
.... then some code after this that uses list
} /* end of func_f1() */
int func_f2(void)
{
struct my_struct {
int a;
char *name;
} *list;
..... then some code after this that uses list
} /* end of func_f2() */
As I know the tag of tagged structure will be unique. But gcc-3.3 (for
cygwin) allows this and from the the behaviour of the code I observe,
the scope limited to function.
Can some one explain this. Does K&R say any thing on this.
Or is this a new C standard ?
thanks
Ranga
Can some one explain me the scope and life of a C struct. I saw a
piece of code that look like the following. My lint tool rejects the
code, but gcc accepts the code. I tried to play around with number and
type of the structure member list, still gcc accepts.
/* file f1.c */
int func_f1(void)
{
struct my_struct {
int a;
char *name;
int b;
} *list;
.... then some code after this that uses list
} /* end of func_f1() */
int func_f2(void)
{
struct my_struct {
int a;
char *name;
} *list;
..... then some code after this that uses list
} /* end of func_f2() */
As I know the tag of tagged structure will be unique. But gcc-3.3 (for
cygwin) allows this and from the the behaviour of the code I observe,
the scope limited to function.
Can some one explain this. Does K&R say any thing on this.
Or is this a new C standard ?
thanks
Ranga