[comp.std.c] macro parameter names

henry@utzoo.uucp (Henry Spencer) (11/28/89)

In article <18672@watdragon.waterloo.edu> afscian@violet.waterloo.edu (Anthony Scian) writes:
>What about the library prototypes that are coded "int foo( int x, int y )"
>when they should be "int foo( int __x, int __y )"?

Can you cite chapter and verse for why the parameter names need to be in
the implementation name space?  They don't interfere with user identifiers
of the same name, and it doesn't look to me as if user identifiers of the
same name can interfere with them.
-- 
That's not a joke, that's      |     Henry Spencer at U of Toronto Zoology
NASA.  -Nick Szabo             | uunet!attcan!utzoo!henry henry@zoo.toronto.edu

henry@utzoo.uucp (Henry Spencer) (11/28/89)

In article <1989Nov27.223210.29880@utzoo.uucp> I wrote:
>>What about the library prototypes that are coded "int foo( int x, int y )"
>>when they should be "int foo( int __x, int __y )"?
>
>Can you cite chapter and verse for why the parameter names need to be in
>the implementation name space? ...

Oops.  Anyone comparing the Subject line to the topic will realize that
I must have been half asleep when I wrote that -- I confused macro
parameters (which are not a problem) with function-prototype parameters
(which are).
-- 
That's not a joke, that's      |     Henry Spencer at U of Toronto Zoology
NASA.  -Nick Szabo             | uunet!attcan!utzoo!henry henry@zoo.toronto.edu

rhg@cpsolv.UUCP (Richard H. Gumpertz) (11/28/89)

In article <1989Nov27.223210.29880@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes:
>In article <18672@watdragon.waterloo.edu> afscian@violet.waterloo.edu (Anthony Scian) writes:
>>What about the library prototypes that are coded "int foo( int x, int y )"
>>when they should be "int foo( int __x, int __y )"?
>
>Can you cite chapter and verse for why the parameter names need to be in
>the implementation name space?  They don't interfere with user identifiers
>of the same name, and it doesn't look to me as if user identifiers of the
>same name can interfere with them.

What if "x" or "y" is #defined by the program before the site of the
declaration of foo?

-- 
===============================================================================
| Richard H. Gumpertz rhg%cpsolv@uunet.uu.NET -or- ...uunet!amgraf!cpsolv!rhg |
| Computer Problem Solving, 8905 Mohawk Lane, Leawood, Kansas 66206-1749      |
===============================================================================

karl@haddock.ima.isc.com (Karl Heuer) (11/30/89)

In article <1989Nov27.223210.29880@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes:
>In article <18672@watdragon.waterloo.edu> afscian@violet.waterloo.edu (Anthony Scian) writes:
>>What about the library prototypes that are coded "int foo( int x, int y )"
>>when they should be "int foo( int __x, int __y )"?
>
>it doesn't look to me as if user identifiers of the same name can interfere
>with them.

I believe that
	#define x 0
	#include <stdlib.h>
	int main(void) { return x; }
is a strictly conforming program, but it would break if the header uses "x" as
an identifier.

However, I don't agree that this is a mistake in the document.  The prototypes
in the document are merely an anchor for discussing the semantics of the
function; they are not "examples" of how the vendor can legally implement the
header.  Note that prototypes are also supplied for functions that must be
implemented as macros.

Karl W. Z. Heuer (harvard!ima!karl or karl@ima.isc.com), The Walking Lint