Re: Newbie question on unions

From: Ron Natalie (ron_at_sensor.com)
Date: 10/11/04


Date: Mon, 11 Oct 2004 10:05:29 -0400

Rolf Magnus wrote:

> Reading a member of a union after writing to another one is not allowed in
> C++. Most platforms I know will just give you a reinterpretation of the two
> char values as one short value, but the right tool to do this is a
> reinterpret_cast.

Except in the case of reading from a char or unsigned char aliased to
something else (unfortuntaely, this is the opposite of what is happening
in this case).



Relevant Pages

  • Re: Reading a Binary File....
    ... I have a problem in reading a binary file. ... int acountnum; ... char phone; ...
    (comp.lang.c)
  • [9fans] Questions on notes
    ... top of that there always seems to be a race condition between somebody reading on /proc/n/note ... Speaking of constant polling: the following hangs 9vx for good on my system: ... void door_bell(void* dummy, char* note) ... int main ...
    (comp.os.plan9)
  • Re: "has been reading" and "was reading"
    ... Char se temas pri la lasta, ... > - has been reading: legas ... inter la signifo de 'Father had been reading', ...
    (soc.culture.esperanto)
  • Re: Finding potions of exchange, where ?
    ... out the inhabitants of D50 (no wands of destruction). ... YAVP's are quite common and really nothing special I'm thinking of aiming ... starvation is no problem if one hyper-overbloats the char (by first ... reading. ...
    (rec.games.roguelike.adom)
  • Re: save array to file, read it back in
    ... reading and writing process usually doesn't take much time. ... void SaveArray(CString Filename,unsigned char *pBuffer,long Size) ... //first write out the array size ... Another idea would be to write the value to the registry so you don't ...
    (microsoft.public.vc.mfc)