Machine specific predefined names

Chris Torek chris at mimsy.UUCP
Tue Mar 15 18:11:10 AEST 1988


In article <302 at wsccs.UUCP> terry at wsccs.UUCP (terry) writes:
>I don't believe everybody will rewrite their UNIX in ANSI C, anyway, so lets
>all hold our breath, and it will go away, leaving only K&R and some idiots
>blinking their eyes at the sudden light.

This is, I think, naive.  A number of vendors are fanatically tracking
the dpANS even now.  4BSD may be slow to follow (as in `you will have
to wait for 4.4BSD to have even a faint hope of seeing an
ANS-conforming compiler' [well, you can try GNU CC in the interim]),
and I believe some vendors will provide two flavours of C (to work
around the botches[1] in the standard until everyone can change their
code), but the standard looks very real.

-----
[1] E.g., widening rules for unsigned (yes, I am going to harp on that
one forever).
-----

As an aside, terry asks us to run the following to see why, he believes,
people need to write their own `printf' functions, spurning those in
the supplied libraries:

>	#include <stdio.h>
>	main()
>	{
>		printf( NULL);
>	}
>
>Some systems will core dump, some systems will do nothing, and others will
>print the string '(NULL)' (my quotes).

True.  Some might even catch your bugs at compile time!  If
you do that, all bets are off, just as if you do *this*:

	main()
	{
		float f;
		int *p = (int *)&f;

		*p = 0x00008000;
		printf("%g\n", f);
		exit(0);
	}

Run it on a Vax and you will get `Illegal instruction (core dumped)',
because the bit pattern 0x00008000 is reserved and is an illegal float.

Note that the line

	printf(NULL);

contains two bugs.  First, it should be

	printf((char *)NULL);

and second, printf is not supposed to be passed (char *)NULL.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list