From: hat AT se-46 DOT wpa DOT wtb DOT tue DOT nl () Newsgroups: comp.os.msdos.djgpp Subject: Re: Unions... Date: 26 May 1998 14:57:45 GMT Organization: Eindhoven University of Technology, The Netherlands Lines: 32 Message-ID: <6kel99$8v5@tuegate.tue.nl> References: <6keg38$mia$1 AT infa DOT central DOT susx DOT ac DOT uk> Reply-To: a DOT hofkamp AT wtb DOT tue DOT nl NNTP-Posting-Host: se-46.wpa.wtb.tue.nl Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk [Posted and mailed] In article <6keg38$mia$1 AT infa DOT central DOT susx DOT ac DOT uk>, andrewda AT cogs DOT susx DOT ac DOT uk (Andrew Smythe Davidson) writes: > Basically I'm looing for a way to create a structure full of registers, some > of which are 16bit, some 8 bit, and some either 8 or 16. Rather than have to > access it in a regs.?.? way like Union REGS regs would give me I'd like to be > able to refer to the 8/16 bit registers either as, for example, regs.a or > regs.ah/regs.al. Is there anyway of doing this without introducing an extra > level into the structure? Yes, just #define the double regs reference to a single reference. So if you want to access regs.a[0] as regs.al, just define #define al a[0] (and don't use al anywhere else). BTW, by using unions in this way you assume a certain memory layout which is neither portable across different compilers, nor across platforms. IMHO you'd better think a bit more, and come up with a data structure which is portable. At least you can then assume that the code might work on the next version of DJGPP. Albert --- The @wtb.tue.nl domain is known to bounce mail incorrectly sometimes. If you are one of the lucky persons, please try again, and send the log as well, so I can prove it to our postmaster. Thank you !