www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/04/03/06:30:29.1

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: implicit declaration of function `int min(...)'
Date: 3 Apr 2002 11:29:06 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 27
Message-ID: <a8ep22$moa$1@nets3.rz.RWTH-Aachen.DE>
References: <5b829932 DOT 0204020845 DOT 4de3b671 AT posting DOT google DOT com>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 1017833346 23306 137.226.32.75 (3 Apr 2002 11:29:06 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 3 Apr 2002 11:29:06 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Francesco Moi <francescomoi AT europe DOT com> wrote:
> Within it, it appears:
> 	short number=min(100,anothernumber);

> And I get this error message:
> 	implicit declaration of function `int min(...)'

Then that code is either unportable, or plain and simply buggy.

> Does anybody have any experience about including 'min' function?

Yes. The experience is that just about no C platform provides a
prebuilt 'min' function, so the above code would not compiler there.
That's mainly because you would need not just one, but rather a whole
slew of such functions, since you may want to take the minimum of a
pair of expressions in a wide range of types, from unsigned char to
long double.

Most C programmers would use a MIN macro, instead:

	#define MIN(a,b) ((a)<(b) ? (a) : (b))

This has its own problems, but it has the benefit that you need only
this one, and it works for all numeric types.
-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019