🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #205

Re: min, max, and ANSI

#205
From: Richard A. O'Keefe
Date: Mon, 13 Apr 1992 07:48
39 lines
2151 bytes
In article <1992Apr9.165859.18578@wam.umd.edu> krc@wam.umd.edu (Kevin R. Coombes) writes:
> I have a question about the ANSI C header stdlib.h. A certain compiler that
> shall for the moment remain nameless includes macros for min(a,b) and 
> max(a,b) in <stdlib.h>.

In article <1992Apr10.162327.29202@borland.com>, pete@borland.com (Pete Becker) writes:
> 	If you compile in ANSI mode (with the -A switch), min and max go
> away.  They also go away when compiling C++.
> 	-- Pete

Turbo C 2.01 does have problems in its <stdlib.h> which the -A option does
not fix.  Example:

	int boo[2];
	#define state 0[boo]
	#define seed  1[boo]
	#include <stdlib.h>
	...

I hadn't noticed this before today, because I hadn't used tcc before today.
It turns out that most of the functions defined in stdlib.h have identiers
in their prototypes, and those identifiers are in the user's name space.

Then of course there's <assert.h>, with Borland's manual explicitly
saying that assert "turns into an if statement".

Where are the *standard* C compilers?  (Ok, I know about Norcroft, but
last I heard they didn't have a compiler for PCs or Encore Multimaxes.)

I spent several hours last week writing a <stdio.h> for Gcc on an
Encore Multimax; not having one it picked up the /usr/include/stdio.h,
and in strict ANSI mode it didn't #define n16, so the record structure
for a stream control block was wrong.  Result: happy compiler, insane
program.  Where are the *standard* C compilers?

-- 
I am writing a book on debugging aimed at 1st & 2nd year CS students using
C/Modula/Pascal-like languages.  Please send suggestions (other than "you
_must_ cite "C Traps and Pitfalls") to ok@goanna.cs.rmit.oz.au
Technical Details
Message-ID: <10209@goanna.cs.rmit.oz.au>
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!bruce!goanna!ok
References: <1992Apr9.165859.18578@wam.umd.edu> <1992Apr10.162327.29202@borland.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!bruce!goanna!ok
From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe)
Newsgroups: comp.std.c,comp.std.c++
Subject: Re: min, max, and ANSI
Message-ID: <10209@goanna.cs.rmit.oz.au>
Date: 13 Apr 92 07:48:16 GMT
References: <1992Apr9.165859.18578@wam.umd.edu> <1992Apr10.162327.29202@borland.com>
Followup-To: comp.std.c
Organization: Comp Sci, RMIT, Melbourne, Australia
Lines: 39