Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!mit-eddie!genrad!decvax!decwrl!sun!gorodish!guy From: guy@gorodish.UUCP Newsgroups: comp.lang.c Subject: Re: Order of registers Message-ID: <13646@sun.uucp> Date: Thu, 19-Feb-87 14:23:37 EST Article-I.D.: sun.13646 Posted: Thu Feb 19 14:23:37 1987 Date-Received: Fri, 20-Feb-87 22:09:02 EST References: <3950004@nucsrl.UUCP> <83@ucdavis.UUCP> Sender: news@sun.uucp Reply-To: guy@sun.UUCP (Guy Harris) Organization: Sun Microsystems, Mountain View Lines: 46 >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.