Register arguments (was: Order of registers)
guy at gorodish.UUCP
guy at gorodish.UUCP
Tue Mar 3 15:12:02 AEST 1987
>> extern int foo(register int i);
>> int foo(register int i) { ... }
>>[These declarations] could cause "i" to be passed in a register.
>
>You imply that the declaration "extern int foo(int)" (without "register") is
>incompatible with the definition "int foo(register int i) { ... }". Does
>X3J11 really say this?
Unfortunately, what X3J11 says is that the "register" in the
declaration would be ignored. It might be nice to have a #pragma or
a compiler flag that caused it to pass "i" in a register in this
case, although this would require people make sure that function
declarations and definitions match - but then, people should make
sure of that *anyway*, e.g. by having the declaration in an include
file and making sure you include that file in every module that
defines a function declared in that include file.
One problem with this, though, is that it conflates a specification
of the abstract characteristics of the function (namely, the types of
its arguments) with the specification of an implementation detail
(namely, the machine-language calling sequence for the function), and
contradicts the advisory nature of "register" declarations. A
#pragma might be a better way of specifying details of the calling
sequence; it could also, e.g., indicate which of several instructions
are to be used for the call. (I believe BLISS had a notion of this
sort.) Again, care would have to be taken to ensure that the #pragma
near the declaration agrees with the #pragma near the definition.
More information about the Comp.lang.c
mailing list