Mail Archives: djgpp/2000/12/18/15:15:15
John Vasquez <jvasquez AT getntds DOT spam DOT com> wrote:
> Found the fix.
No. You found an ugly workaround, IMHO.
> If I do the following in the structure, The error disappeared.
> int Myfunct(int x, void *adr);
> typedef struct _MyStruct{
> int (*funct)(); //don't include the parameter list
> }MyStruct;
That's bad coding practice. You should, by all means, leave the
parameter types in the function pointer typed element of your
structure. Your declaration makes proper type checking by the
compiler impossible. In particular, it now won't warn even if you
assign to the pointer a function taking a char[30] and a double as it
arguments.
You may want to make things easier by using a typedef for the function
pointer type:
typedef int (*MyFunctPtr) (int, void*);
And then declare
MyFunctPtr Myfunct;
typedef struct {
MyFunctPtr funct;
} MyStruct;
The typedef may also make your program work. In C, it can sometimes make
a difference wether you declare a same-looking type twice, or only once.
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -