Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!wuarchive!udel!rochester!kodak!ispd-newsserver!ism.isc.com!b1!ico!auto-trol!marbru From: marbru@auto-trol.com (Martin Brunecky) Newsgroups: comp.windows.x.motif Subject: Re: writing Widgets with Float resources Message-ID: <1991May31.180954.23462@auto-trol.com> Date: 31 May 91 18:09:54 GMT References: <13743@dog.ee.lbl.gov> Sender: news@auto-trol.com Organization: Auto-trol Technology Corporation Lines: 37 Nntp-Posting-Host: server_1-gw In article <13743@dog.ee.lbl.gov> anderson@rubato.lbl.gov () writes: > >I have started to write a few Motif widgets (subclassing Primitive, >for instance), and have things working fine as long as various >resources are "ints" (XmRInt type resources). But I need them >to be "floats" (XmRFloat types). > >It appears that no matter what I try, XtSetValues passes junk >as the float; as soon as I get into my SetValues function and >take a look at what is passed, I get some bizarre value. We do use WsRFloat resources (as well as WsRDouble, but those are passed by reference). Your problem is not that mysterious. It is the "C" compiler which typecasts the "value", and for the conversion from float it does what you see. The way we do SetValues on WsRFloat resources is .... typedef union u { long int int; float float; } u value; value.float = desired float value XtSerArg ( arg[n], WsNangle, value.int ); This way, the typecast in SetArg does no damage, and we get our floats delivered right. -- =*= Opinions presented here are solely of my own and not those of Auto-trol =*= Martin Brunecky marbru%auto-trol@sunpeaks.central.sun.com (303) 252-2499 (better avoid: marbru@auto-trol.COM ) Auto-trol Technology Corp. 12500 North Washington St., Denver, CO 80241-2404