home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!wupost!waikato.ac.nz!ldo
- From: ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: short/long ints (was Re: Sozobon C...)
- Message-ID: <1993Jan5.174802.13028@waikato.ac.nz>
- Date: 5 Jan 93 17:48:02 +1300
- References: <29848@castle.ed.ac.uk> <3917@isgtec.isgtec.com> <C0AKGC.IsJ@news.cso.uiuc.edu> <1993Jan4.202040.26524@reed.edu>
- Organization: University of Waikato, Hamilton, New Zealand
- Lines: 30
-
- In article <1993Jan4.202040.26524@reed.edu>, bowman@reed.edu (BoBolicious) writes:
- >
- > I *guess* you could talk about a "Mac int standard", but what's really going
- > on is that Pascal uses 16-bit ints. Most C compilers these days use 32-bit
- > ints. Personally, I think ints are stupid to use, because of this uncertainty
- > as to what is meant; far better to specifically use shorts & longs.
-
- Back when I used to program voluntarily in Fortran, I developed this convention
- that I would explicitly use INTEGER*2 or INTEGER*4 wherever it mattered, and
- just use INTEGER wherever it didn't. This way my code could compile with
- either the /I4 (INTEGER = INTEGER*4) or /NOI4 (INTEGER = INTEGER*2) switch,
- and so long as I used the same switch setting with all my modules, the final
- program would run OK.
-
- Now that I use Modula-2, I have adopted the same convention. The compiler
- I use interprets INTEGER and CARDINAL types as 16 bits, and LONGINT and
- LONGCARD types as 32 bits. What I did was define ShortInt and ShortCard
- types in my Types.def interface file, and I use these (and LONGINT/LONGCARD)
- where it matters, leaving direct use of INTEGER and CARDINAL for those places
- where it doesn't. This way I only need to make a change in one place. I don't
- even have to worry about compiling different parts of the same program with
- different versions of the interface file, as Modula-2 doesn't allow you to
- make that kind of mistake.
-
- Lawrence D'Oliveiro fone: +64-7-856-2889
- Computer Services Dept fax: +64-7-838-4066
- University of Waikato electric mail: ldo@waikato.ac.nz
- Hamilton, New Zealand 37^ 47' 26" S, 175^ 19' 7" E, GMT+13:00
- If there is no such thing as a free lunch, then where did the universe
- come from?
-