Mail Archives: djgpp/2000/12/19/11:37:57
I know your right, that was just a work around and I know the purpose
of doing the proper declaration.
I must have declare the wrong parameter types in the function pointer
typed element yesterday and just didn't see what I did wrong.
I added the proper parameter types this morning and the warning error
did not appear.
Thanks for your response.
John
>structure.
On 18 Dec 2000 19:45:39 GMT, Hans-Bernhard Broeker
<broeker AT physik DOT rwth-aachen DOT de> wrote:
>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 -