Reserved words in C

Doug Gwyn gwyn at brl-smoke.ARPA
Wed Jan 7 02:34:01 AEST 1987


In article <1199 at ucbcad.berkeley.edu> faustus at ucbcad.berkeley.edu (Wayne A. Christopher) writes:
>If a standard library has a function called 'read' in it, I don't see how
>this could alter the *behavior of the program* ...

/*	Demonstrate problem with extensions in the C library	*/

#include <stdio.h>

extern int	read();

int
main()	{
	int	c = read();

	(void) printf( "Got: 0%o\n", c );
	return 0;
	}

/*	The following might be in a separate file, so that
	external linkage will be forced to occur as expected	*/
int
read()	{
	return getchar();
	}

On a system (such as UNIX) where getchar() is implemented via an
eventual call to a function named read() in the C library, this
program will go bonkers, even though it is strictly conforming.



More information about the Comp.lang.c mailing list