Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!samsung!munnari.oz.au!kaukau.comp.vuw.ac.nz!virtue!ccc_ldo From: ccc_ldo@waikato.ac.nz Newsgroups: comp.sys.mac.programmer Subject: Re: Re: dead code, brain dead lilbrary Message-ID: <166.25e0277b@waikato.ac.nz> Date: 19 Feb 90 05:25:06 GMT References: <1990Feb14.204332.24800@caen.engin.umich.edu> <20062@bellcore.bellcore.com> <10294@hoptoad.uucp> <2971@draken.nada.kth.se> Lines: 22 In article <2971@draken.nada.kth.se>, d88-jwa@nada.kth.se (Jon Watte) writes: >In article <10294@hoptoad.uucp> tim@hoptoad.UUCP (Tim Maroney) writes: >>The proper way to write atoi on the Macintosh is: >>int atoi(StringPtr s) { long i; StringToNum(s, &i); return i; } > ~~~ ~~~~ ~~~~~~~~ >>Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com >I can't believe this ! >Any sane compiler would complain. If you reurn a long, the >function should be declared long. If you use int, you're wide >open for all kinds of incompatibilities. Int is intended only >for holding "a small integer value", and you can never assume >it can take a value higher than 32767. (Look in the standard) The compiler converts the type of the "return" expression to match the type returned by the function. Try changing the type of the above "atoi" function from "int" to "short", and have a look at the generated code, to see what I mean.