register unions
James Jones
jejones at mcrware.UUCP
Sun Feb 21 00:59:10 AEST 1988
In article <7258 at brl-smoke.ARPA>, gwyn at brl-smoke.ARPA (Doug Gwyn ) writes:
> On the other hand, I don't think this is nearly as useful as
> you seem to think it would be. Why would you want to twiddle
> specific registers when not having to be concerned with such
> matters is the whole point of using a higher-level language?
The place I can see people wanting unions to live in registers is something
like
register union {
woof *wp;
char *cp;
...
} mumble;
(Actually, this isn't great insight on my part; I've heard people say,
"Gee, it would be nice if a compiler let you do this...") There are some
low-level cases in which one would like to add a byte offset to a pointer
that usually points at something bigger than one byte, and still keep the
pointer in a register.
(Of course, compilers should all be smart enough to figure out what should go
in registers themselves, right? We don't need no steenkin' register declara-
tions! :-)
(I *do* recognize the advantages of letting the compiler figure out what can
go into a register, what the lifetimes of such variables are, etc.--it's
just that if the compiler *can* really put such a union in a register itself,
it seems to me that the programmer should be able to specify explicitly that
he thinks it's important that the union be in a register.)
James Jones
More information about the Comp.lang.c
mailing list