On Fri, 21 Sep 2012, Marcin Cieslak wrote: > + union { > + XtPointer ptr; > + Dimension dim; > + } wide;
> + XtVaGetValues(dir_label, XmNwidth, &wide.ptr, NULL); > + d_width = wide.dim; > + XtVaGetValues(file_label, XmNwidth, &wide.ptr, NULL); > + f_width = wide.dim; Sorry, this is wrong - it fail on 64-bit big endian platform with 32-bit ints (tried on 64-bit Solaris 9). Of course, we can do: XtPointer wide; Dimension d_width, f_width; XtVaGetValues(dir_label, XmNwidth, &wide, NULL); d_width = (Dimension)wide; XtVaGetValues(file_label, XmNwidth, &wide, NULL); f_width = (Dimension)wide; but this will cause "cast from pointer to integer of different size" warnings. C99 solution to this is: #include <inttypes.h> ... XtPointer wide; Dimension d_width, f_width; XtVaGetValues(dir_label, XmNwidth, &wide, NULL); d_width = (Dimension)(uintptr_t)wide; but not everyone is getting C99 integer types. It has even been reported as a bug: http://bugs.motifzone.net/show_bug.cgi?id=1497 What is the proper practice to cast XtPointer safely among X developers? We need to fix all cases of: int something; XtVaGetValues(...,...,XmSomething, &something, ...); since this causes overwrite of the neighbouring values on the stack (and was the cause of dtfile crash). //Marcin ------------------------------------------------------------------------------ How fast is your code? 3 out of 4 devs don\\\'t know how their code performs in production. Find out how slow your code is with AppDynamics Lite. http://ad.doubleclick.net/clk;262219672;13503038;z? http://info.appdynamics.com/FreeJavaPerformanceDownload.html _______________________________________________ cdesktopenv-devel mailing list cdesktopenv-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/cdesktopenv-devel