register unions

Richard A. O'Keefe ok at quintus.UUCP
Mon Feb 22 14:26:23 AEST 1988


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;
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.  {There are also the "Field Address" and
"Field Length" registers, one set of which overlaps a floating-point
register...}

If you really need to do this, you can manage it with casts.
The cast version is a wee bit better than the union version,
because Lint will complain about the casts, but the union code
will just quietly do something surprising.

	for (times = 100; --times >= 0; ) {
	    fprintf(stderr, "Byte addressing is not universal.\n");
	    fprintf(stderr, "Pointers may come in different sizes.\n\n");
	}



More information about the Comp.lang.c mailing list