Top Document: comp.windows.x.intrinsics Frequently Asked Questions (FAQ) Previous Document: 15. What alternatives to the Intrinsics are there? Next Document: 17. How do I write a resource converter? See reader questions & answers on this topic! - Help others by sharing your knowledge ---------------------------------------------------------------------- First, what is going wrong is the structure for an Arg is (essentially) typdef struct { String name; long value; } Arg; and the code: Arg arg; XtSetArg (arg, "name", 3.2) expands to Arg arg; arg.name = "name"; arg.value = 3.2; you can see that with normal C type conversions, the arg.value gets the integer "3" instead of the floating point value "3.2". When the value is copied into the widget resource, the bit pattern is wildly different than that required for a floating point value. So, how to get around this? The following macro is from the Athena widgets document and I am now recomending it over the previous suggestions. #define XtSetFloatArg(arg, n, d) \ if (sizeof(float) > sizeof(XtArgVal)) { \ XtSetArg(arg, n, &(d)); \ } else { \ XtArgVal *ld = (XtArgVal *)&(d); \ XtSetArg(arg, n, *ld); \ } User Contributions:Top Document: comp.windows.x.intrinsics Frequently Asked Questions (FAQ) Previous Document: 15. What alternatives to the Intrinsics are there? Next Document: 17. How do I write a resource converter? Single Page [ Usenet FAQs | Web FAQs | Documents | RFC Index ] Send corrections/additions to the FAQ Maintainer: ware@cis.ohio-state.edu
Last Update March 27 2014 @ 02:11 PM
|
Comment about this article, ask questions, or add new information about this topic: