Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!sri-spam!ames!oliveb!pyramid!uccba!hal!ncoast!jae From: jae@ncoast.UUCP (Jeff Evans) Newsgroups: comp.lang.c,comp.sys.ibm.pc Subject: Re: MSC toupper (was Re: MS-DOS NRO ) Message-ID: <2576@ncoast.UUCP> Date: Sun, 31-May-87 16:37:42 EDT Article-I.D.: ncoast.2576 Posted: Sun May 31 16:37:42 1987 Date-Received: Wed, 3-Jun-87 04:08:58 EDT References: <405@ritcv.UUCP> <725@thumper.UUCP> <345@polyslo.UUCP> <348@polyslo.UUCP> Distribution: na Organization: Cleveland Public Access UN*X, Cleveland, OH Lines: 37 Keywords: NRO Summary: toupper is a function AND a macro ... Xref: mnetor comp.lang.c:2299 comp.sys.ibm.pc:4510 In article <348@polyslo.UUCP>, mpatnode@polyslo.UUCP (Mike Patnode) writes: > In article <2065@husc6.UUCP> ddl@husc6.UUCP (Dan Lanciani) writes: > >In article <345@polyslo.UUCP>, mpatnode@polyslo.UUCP (Mike Patnode) writes: > >> toupper(p++) > >> This is a BIG NO-NO since toupper is actually a macro which > >> evaluates it's arguments 3 times!!!!! > > > > Not quite. This is a no-no, but for a different reason. The macros > >toupper and tolower do not evaluate their arguments more than once. (At > >least on BSD and MSC 4.0 and other "compatible" systems.) In order to > >avoid multiple eveluation, these macros do NOT check that their arguments > >are suitable. > Well Dan this is straight out of my ctype.h: > > #define toupper ((isupper(c)) ? _tolower(c) : (c)) > > Upon closer evaluation I now see the argument is only evaluated 2 > times. But this was with MSC 3.00 so 4.0 may have change. Here it is, straight from the horses mouth ... (Microsoft C 4.0 Runtime Lib. Manual p. 406 [for toascii - toupper]) These functions are implemented as macros. However, tolower and toupper are also implemented as functions, because the macro versions do not correctly handle arguments with side effects. The function versions can be used by removing the macro definitions through #undef directives or by not including ctype.h. Function declarations of tolower and toupper are given in stdlib.h. I had the same problem using the macro version of toupper, but the problem disappeared with the function version. -- |-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-| | Jeff Evans Bailey Controls Co. - Systems Engineering | | Path: ...cbosgd!cwruecmp!ncoast!jae Domain: jae@ncoast.UUCP | |=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=| Disclaimer : My views are of my own creation ... I had no help.