Path: utzoo!utgpu!watserv1!watmath!att!cbnewsk!ech From: ech@cbnewsk.ATT.COM (ned.horvath) Newsgroups: comp.sys.mac.programmer Subject: Re: dead code, brain dead lilbrary Message-ID: <2088@cbnewsk.ATT.COM> Date: 19 Feb 90 22:45:44 GMT References: <2971@draken.nada.kth.se> Organization: AT&T Bell Laboratories Lines: 22 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 From article <2971@draken.nada.kth.se>, by d88-jwa@nada.kth.se (Jon Watte): > 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... Sorry, Tim is absolutely right. The Portable C Library standard defines atoi as returning int (not long, not short). StringToNum returns a long. int and long are always compatible, so a compiler might warn, but not fail, when passed Tim's routine. Life isn't always so simple... =Ned Horvath=