On Oct 24, 7:32 am, Alessandro Basili <
alessandro.bas...@cern.ch>
wrote:
> Hi all,
> I'm fairly new to X Windows but quite fascinated by Motif (Lesstif on my
> GNU/Linux system).
>
> As every beginner, I started from a very simple example found here:
>
>
http://www.cs.cf.ac.uk/Dave/X_lecture/node5.html#SECTION0050000000000...
>
> but when I compile I get the following warning:
>
> > push.c:39: warning: passing argument 3 of ‘XtAddCallback’ from incompatible pointer type
> > /usr/include/X11/Intrinsic.h:1244: note: expected ‘XtCallbackProc’ but argument is of type ‘void (*)(struct _WidgetRec *, void *, struct XmPushButtonCallbackStruct *)’
>
> The program works, but I'm not quite confident in passing incompatible
> pointers around. The pushed_fn function is of type void and I understand
> that XtAddCallback would expect an XtCallbackProc type but not sure how
> to pass this.
> Any help is appreciated.
>
When you add a callback, your call should look likt this:
MyData *myData = ...;
XtAddCallback( widget, XmNxxxCallback, myProc, myData );
where myProc is your callback function, whose signature should be:
void myProc( Widget w, XtPointer clientData, XtPointer callData);
Note that you should NOT declare callData as
(XmPushButtonCallbackStruct (). You should instead cast it in your
function body:
void myProc( Widget w, XtPointer clientData, XtPointer callData) {
XmPushButtonCallbackStruct *cbs = (XmPushButtonCallbackStruct
*)callData;
MyPassedType *myType = (MyPassedType *)clientData;
}
--
Fred K