Token pasting in #include directive

Rex Jaeschke rex at aussie.UUCP
Fri Dec 1 03:14:52 AEST 1989


> In article <18672 at watdragon.waterloo.edu>, afscian at 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 )"?
> 
> Eh?  Why is the second any more correct than the first?  Since

I raised this in a paper at the Nashua, NH X3J11 meeting in 1988. It 
was agreed that the prototypes in the library section of the draft 
were NOT CONFORMING since they were in the user's namespace. The 
result was that I sumbitted words for the Rationale document 
explaining how they should really have been defined. See page 22 
bottom half of the Rationale, Nov '88.

For those of you without that document my examples contained something 
like the following (among other things):

	#define str *
	#include <string.h>
	
Consider that in string.h you have:

	size_t strlen(char *str);

After macro substitution, the prototype becomes:

	size_t strlen(char **);

and all your calls to strlen will fail because the types don't match. 
The bottom line is that you must not be able to rewrite a standard 
prototype from within a conforming program.

Rex

----------------------------------------------------------------------------
Rex Jaeschke     |  Journal of C Language Translation  | C Users Journal
(703) 860-0091   |        2051 Swans Neck Way          | DEC PROFESSIONAL
uunet!aussie!rex |     Reston, Virginia 22091, USA     | Programmers Journal
----------------------------------------------------------------------------
Convener of the Numerical C Extensions Group (NCEG)
----------------------------------------------------------------------------



More information about the Comp.std.c mailing list