Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!wuarchive!mit-eddie!mintaka!olivea!oliveb!pyramid!voder!apple!sun-barr!rutgers!cmcl2!lanl!jlg From: jlg@lanl.gov (Jim Giles) Newsgroups: comp.society.futures Subject: Re: C's sins of commission (was: (pssst...fortran?)) Message-ID: <&3646@lanl.gov> Date: 21 Sep 90 00:05:27 GMT References: <9009202211.AA15218@encore.encore.com> Organization: Los Alamos Natl Lab, Los Alamos, N.M. Lines: 27 From article <9009202211.AA15218@encore.encore.com>, by pmorris@BBN.COM (Phil Morris): > [...] |> How about something as simple as: |> |> #define SZLONG sizeof(long) |> |> union xxx { |> long word; |> char str[SZLONG]; |> } un; |> |> un.word = '1234'; |> printf("%c %c %c %c\n", un.str[0], un.str[1], un.str[2], un.str[3]); |> |> |> It works on my machine, and the hypothetical language under discussion can handle these |> constructs (except he didn't mention how to do sizeof(xxx)). Actually, I prefer sizeof() to be measured in bits, not bytes. And I prefer 'union' to be non-storage order dependent. I actually prefer the use of 'mapping' declarations (such as I described in the first article I posted with this title). Other than that, your solution is mech like the one I sent via email to the person who posted the problem. J. Giles