Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XtPointer

Status
Not open for further replies.

BStopp

Programmer
Dec 29, 2003
29
US
Ok, been frying my brain for a while now, so gonna ask for help.

Been asked to update this application from 32-bit to 64-bit. It uses something called Widgets and XtPointers. Now, i have no idea what they are and don't really care. The problem i have is when i try to compile the file i get the following errors:

"date_callbacks.c", line 235: Error: Cannot cast from void* to int.
"date_callbacks.c", line 357: Error: Cannot cast from void* to int.


The applicaiton casts the XtPointer into an int like so:

Code:
int idx = (int) client_data;

client_data is of type XtPointer... From what i've read about XtPointers is that it is a pointer to a block of memory that can hold pretty much the largest of values of certian types. And if you put a specific type in there you can just cast it out and back again as needed.

Is there any reason why I get this error? Any and all help would be appreciated.

-B
 
XtPointer is a void* used by X Windows.

You can fix it by passing a pointer to the data instead of the data itself. Look for XtAddCallback: the last parameter is the client data which is cast to an XtPointer. Pass the address of the client data instead of the value.
 
For compiling on a AMD Opteron machine I did the following (see the declaration and action on client_data):


void file_save_cb(Widget widget, XtPointer client_data, XtPointer call_data)
{
XmString button, button2, title, pattern, dirmask;

#ifdef bit64
long reason = (long)client_data;
#else
int reason = (int)client_data;
#endif

dirmask = XmStringCreateLocalized (".");

switch (reason)
{
case SAVE_GIF:
case SAVE_GIF_XSEC:
case SAVE_GIF_PROFILE:
.
.
.
 
This does not answer your question, but why would anyone cast a void pointer to an int? I cant think of any good reason and it is bad programming practice, which is why it was not portable.
 
int i = 68;
void *client_data;
client_data = (void*)i;
int idx = (int)client_data;

no problems in borland here.

question;
how is a xtpointer different from a good ole void*.

did you modify this aspect of the code or is this
original to the project form the start. meaning it
compiled when the code was originally written.

replace the void pointer with yur xtpointer in a
test file. does it work.

and lastly are you sure you got the proper library files
to access this xtpointer.



perhaps, maybe , Idontknow, nevermind

TC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top