Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!ames!oliveb!sun!gorodish!guy From: guy@gorodish.UUCP Newsgroups: comp.lang.c Subject: Re: Register arguments (was: Order of registers) Message-ID: <14382@sun.uucp> Date: Tue, 3-Mar-87 00:12:02 EST Article-I.D.: sun.14382 Posted: Tue Mar 3 00:12:02 1987 Date-Received: Thu, 5-Mar-87 20:29:42 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: 27 Keywords: ANSI function prototype >> 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.