Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!sdd.hp.com!hplabs!hpcc05!hpbbn!hpgnd!alex From: alex@hpgnd.grenoble.hp.com (Alexis MERMET-GRANDFILLES) Newsgroups: comp.lang.c Subject: ANSI C and typedef of function types Message-ID: <340001@hpgnd.grenoble.hp.com> Date: 28 Jun 91 12:19:03 GMT Organization: Hewlett-Packard, GND Lines: 48 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 -------------------------------------------------------------------------