From: jvasquez AT getntds DOT spam DOT com (John Vasquez) Newsgroups: comp.os.msdos.djgpp Subject: Re: pointer to functions - Warning error Date: Tue, 19 Dec 2000 16:16:08 GMT Organization: CTSnet Internet Services Lines: 54 Message-ID: <3a3f88d6.86071564@news.connectnet.com> References: <3a3e5883 DOT 8164479 AT news DOT connectnet DOT com> <3a3e6258 DOT 10681619 AT news DOT connectnet DOT com> <91lph3$7kp$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> X-Trace: thoth.cts.com 977242574 60862 207.110.36.153 (19 Dec 2000 16:16:14 GMT) X-Complaints-To: abuse AT cts DOT com X-Newsreader: Forte Free Agent 1.21/32.243 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com 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 wrote: >John Vasquez 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.