register unions

Mike My watch has windows Meyer mwm at eris
Tue Feb 23 14:15:32 AEST 1988


In article <677 at cresswell.quintus.UUCP> ok at quintus.UUCP (Richard A. O'Keefe) writes:
<In article <604 at mcrware.UUCP>, jejones at mcrware.UUCP (James Jones) writes:
<> The place I can see people wanting unions to live in registers is something
<> like
<> register union {
<> 	woof	*wp;
<> 	char	*cp;
<> 	...
<> }	mumble;
<
<	for (times = 100; --times >= 0; ) {
<	    fprintf(stderr, "Byte addressing is not universal.\n");
<	    fprintf(stderr, "Pointers may come in different sizes.\n\n");
<	}

True statements, but they have nothing to do with people wanting to
put unions in registers.

<If you really need to do this, you can manage it with casts.

Do what? You don't know why the union was wanted. Maybe I just want to
reuse that register for multiple things, and have no intention of
using it to copy bits from a (char *) to a (woof *).

<The cast version is a wee bit better than the union version,

Actually, the cast version is a lot better. It gives the compiler the
chance to do something intelligent with the bits before putting it in
the other type of pointer. Doing that kind of thing with a union means
you get raw bits. Then again, that may be what you want.

<Last time I looked at a PR1ME C manual, most pointers were 32 bits, 
<but character pointers were 48 bits.  The P400 (the machine I used)
<has 32-bit registers.

So, because the prime won't let you put (char *) objects in a
register, you think people shouldn't be allowed to declare register
union objects? It'd make more sense to disallow register char *
objects, and any union that they wouldn't fit in. But there are to
many machines where register char * makes sense, so that probably
won't fly.

>From the old dpANS, I'd guess you can declare register unions. You
just can't take the address of the union, or any part of it. Machines
that won't support what you're trying to put into the union in the
register type probably ignore the register - just like they do for a
register object decleration where the object won't fit in a register.

	<mike
--
Estant assis, de nuit secrette estude,			Mike Meyer
Seul, repose sur la selle d'airain,   			mwm at berkeley.edu
Flambe exigue, sortant de solitude,   			ucbvax!mwm
Fait proferer qui n'est a croire vain.			mwm at ucbjade.BITNET



More information about the Comp.lang.c mailing list