home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!stanford.edu!agate!darkstar.UCSC.EDU!cats.ucsc.edu!spencer
- From: spencer@cats.ucsc.edu (Michael Spencer)
- Newsgroups: comp.lang.c++
- Subject: Re: Function 'max' should have a prototype
- Date: 25 Jan 1993 23:36:38 GMT
- Organization: University of California, Santa Cruz
- Lines: 32
- Message-ID: <1k1ti6INNe6c@darkstar.UCSC.EDU>
- References: <hrpctw.14@pnv.palm.cri.nz>
- NNTP-Posting-Host: am.ucsc.edu
-
-
- hrpctw@pnv.palm.cri.nz (Colin T. Wilson-Salt) writes:
-
- >I can't seem to get the max() macro to work. It works OK under C, but
- >under C++ it gives me the error "Function 'max' should have a prototype".
-
- >Should I give up and write a replacement max() function/macro?
-
- Roll your own. It's a lot easier than trying to figure out the
- vagaries of compilers! Try:
-
- #define Minim(a,b) ((a<b) ? a : b)
- #define Maxim(a,b) ((a>b) ? a : b)
- #define InRange(a,lo,hi) ((a<lo) ? 0 : ((a>hi) ? 0 : 1))
- #define RangeSet(a,lo,hi) ((a<lo) ? (a = lo) : (a>hi) ? (a = hi) : a )
- #define CircleSet(a,lo,hi) ((a<lo) ? (a = hi) : (a>hi) ? (a = lo) : a )
-
- The last 3 will help avoid 'fence-post' errors.
-
-
- ===========================================================================
- Michael Spencer | 2640 Borregas
- spencer@cats.ucsc.edu | Aptos, CA 95003
- ===========================================================================
-
- --
-
- ===========================================================================
- Michael Spencer | 2640 Borregas
- spencer@cats.ucsc.edu | Aptos, CA 95003
- ===========================================================================
-
-