[comp.lang.c] ANSI C and typedef of function types

alex@hpgnd.grenoble.hp.com (Alexis MERMET-GRANDFILLES) (06/28/91)

Hello,

X11/Instrinsic.h defines the type "XtEventHandler" as :
=>  typedef void (*XtEventHandler)(Widget, XtPointer, XEvent *,Boolean *);


Let's imagine now that I want to create a new Event Handler called foo.

The routine XtAddEventHandler registers the new event handler :

=> XtAddEventHandler( Widget w, EventMask event_mask, Boolean nonmaskable,
                      XtEventHandler foo, XtPointer client_data) ;

So foo needs to be of type XtEventHandler. Therefore I had in my header file :

foo.h:
=> XtEventHandler foo;

And the definition of the foo routine occurs in the source module:

foo.c:
=> #include "foo.h"
   void foo (Widget w, XtPointer data, XEvent *event, Boolean *cont)
   {
	...
   }


The ANSI compiler then claims the type of foo is incompatible with the
declaration.

I tryied to declare foo in the header file as :
void foo(Widget, XtPointer, XEvent *,Boolean *);

Then the compiler claimed , when calling the XtAddEventHandler , that
the foo parameter is of a wrong type ( void(*)() instead of XtEventHandler ).


So, What am I missing ?

Any help will be very appreciated.

--------------------------------------------------------------------------
Alexis MERMET-GRANDFILLES             HEWLETT-PACKARD
Tel: 76 62 12 11                      Grenoble Network Division
Fax: 76 62 52 00                      5 avenue Raymond Chanas - EYBENS
alex@hpgndxo.hp.com                   38053 GRENOBLE CEDEX 9
-------------------------------------------------------------------------