Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!gatech!amdcad!crackle!tim From: tim@crackle.amd.com (Tim Olson) Newsgroups: comp.lang.c Subject: Re: Unions Message-ID: <23341@amdcad.AMD.COM> Date: 23 Oct 88 20:56:42 GMT References: <322@hrc.UUCP> <2699@hound.UUCP> <976@l.cc.purdue.edu> <8724@smoke.BRL.MIL> <981@l.cc.purdue.edu> Sender: news@amdcad.AMD.COM Reply-To: tim@crackle.amd.com (Tim Olson) Organization: Advanced Micro Devices, Inc. Sunnyvale CA Lines: 28 Summary: Expires: Sender: Followup-To: In article <981@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes: | Here is a very simple example. BTW, I have seen C sources which use precisely | this construction. | | union un {*int i; *float f;}; | | ..... | | register union un var1, var2; | | Can anyone give me any conceivable reason why this union, whose size is | exactly one register on the machines I have tried it on, is not put into | an available register? On one of the machines (Pyramid), local variables | were normally put into registers, but the compiler would not put the union | there. I know this particular case can be done with casts, but other cases | cannot. The MetaWare C compiler for the Am29000 does precisely what you want -- it keeps all register-sized variables in registers, as long as their address isn't taken in the function. This includes unions, structs, and even arrays. Aggregates such as structs are also passed as parameters to functions in registers. -- Tim Olson Advanced Micro Devices (tim@crackle.amd.com)