Order of registers
guy at gorodish.UUCP
guy at gorodish.UUCP
Fri Feb 20 05:23:37 AEST 1987
>Does this imply that some compilers notice the "register" declaration
>and pass the argument in a register? Seems to me this only could be
>done for "static" functions.
Or for other functions, in ANSI C. If you use "register" in the
declaration of the parameter, and if the function *definition* used a
function prototype-style declaration using "register, the compiler
could decide to pass it in a register. (If the function definition
uses the old-style declaration, it wouldn't be able to do this,
because it would break old programs.) Thus
extern int foo(register int i);
in an #include file or a module containing code using "foo", and
int
foo(register int i)
{
...
}
as the definition of "foo" could cause "i" to be passed in a
register. However, the old-style
extern int foo();
in the #include file or module using "foo", and
int
foo(i)
register int i;
{
...
}
as the definition of "foo" would probably not be able to, in most
implementations.
Of course, mixing the two would cause no end of headaches, but then
you *are* including the header file that declares "foo" in the module
that defines "foo", so that type clashes between the declaration and
definition will be caught, aren't you?
Note that some implementations, e.g. those on register-window
machines, may pass some parameters in registers regardless of the
declaration.
More information about the Comp.lang.c
mailing list