Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XtAddCallback - incompatible pointer type

141 views
Skip to first unread message

Alessandro Basili

unread,
Oct 24, 2011, 10:32:05 AM10/24/11
to
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#SECTION00500000000000000000

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.

Al

--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

Fred

unread,
Oct 24, 2011, 1:04:39 PM10/24/11
to
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

Alessandro Basili

unread,
Oct 24, 2011, 4:51:38 PM10/24/11
to
Thanks a lot! I now realize the reference source code I took is not
compatible with the current Intrinsic.h and the declaration of the
XtAddCallback.

Probably I need to look for a more up-to-date tutorial, even though I
really appreciated the structure of that reference.

> --
> Fred K

0 new messages