D
Duncan Muirhead
When I compile the program below "Program start" with
gcc -std=c99 -pedantic -o bgcc bgcc.c
(where gcc --version gives
gcc (GCC) 3.4.5 20051201 (Red Hat 3.4.5-2)
Copyright (C) 2004 Free Software Foundation, Inc.
)
I get the warning
bgcc.c:3: warning: "struct thingTag" declared inside parameter list
bgcc.c:3: warning: its scope is only this definition or declaration, which
is probably not what you want
Should the code generate a warning? Is there a way to avoid it other than
adding
typedef struct thingTag * thingP;
and replacing line 3 with
typedef void (*show)( thingP);
(which does shut gcc up)?
TIA
Duncan
Program start
#include <stdio.h>
typedef void (*show)( struct thingTag *);
typedef struct thingTag
{ show f;
double v;
} thing;
void show_metres( thing* p)
{ printf( "%f m\n", p->v);
}
int main( int argc, char** argv)
{
thing T;
T.v = 1.7;
T.f = show_metres;
T.f( &T);
return 1;
}
gcc -std=c99 -pedantic -o bgcc bgcc.c
(where gcc --version gives
gcc (GCC) 3.4.5 20051201 (Red Hat 3.4.5-2)
Copyright (C) 2004 Free Software Foundation, Inc.
)
I get the warning
bgcc.c:3: warning: "struct thingTag" declared inside parameter list
bgcc.c:3: warning: its scope is only this definition or declaration, which
is probably not what you want
Should the code generate a warning? Is there a way to avoid it other than
adding
typedef struct thingTag * thingP;
and replacing line 3 with
typedef void (*show)( thingP);
(which does shut gcc up)?
TIA
Duncan
Program start
#include <stdio.h>
typedef void (*show)( struct thingTag *);
typedef struct thingTag
{ show f;
double v;
} thing;
void show_metres( thing* p)
{ printf( "%f m\n", p->v);
}
int main( int argc, char** argv)
{
thing T;
T.v = 1.7;
T.f = show_metres;
T.f( &T);
return 1;
}