Jim.Spencer@p5.f22.n282.z1.FIDONET.ORG (Jim Spencer) (02/20/90)
>>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) I don't have the ANSI standard but my understanding is that the length of an int is implementation dependantand an int can be equivalent to a long or a short. In MPW C, an int is equivalent to a long, i.e. 32 bits capable of holding values from -2,147,483,648 to 2,147,483,647. While the typing of C is much stronger under the ANSI standard, I still would prefer that the compiler only complain when sizes really don't match and the larger sized type is being assigned to the smaller. -- Jim Spencer - via FidoNet node 1:282/33 UUCP: ...!uunet!imagery!22.5!Jim.Spencer ARPA: Jim.Spencer@p5.f22.n282.z1.FIDONET.ORG