Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ames!necntc!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: How do a write portable programs? Message-ID: <7229@haddock.ima.isc.com> Date: 9 Sep 88 19:45:15 GMT References: <1056@nmtsun.nmt.edu> <2515@ingr.UUCP> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 19 In article <2515@ingr.UUCP> jones@ingr.UUCP (Mark Jones) writes: >In article <1056@nmtsun.nmt.edu>, warner@hydrovax.nmt.edu (M. Warner Losh) writes: >> write portable 'C' code. Things like don't use 0, use NULL, but be >> sure to always cast it. > >Instead of using NULL, use ZERO, and don't worry about casting it. [Because >K&R guarantees that `0' denotes a null pointer constant.] `NULL' is more meaningful than `0', in a context where it isn't otherwise obvious that you're dealing with a pointer. But since we're talking about portability issues, I'll grant that they're equally good ways to represent a null pointer constant. But the cast is required in one situation: a function argument not covered by a prototype. >#if sizeof(int) == 4 You can't use sizeof() in an #if expression. If you have ANSI C's , you can write as `#if INT_MAX >= 0x7fffffff' to get the effect you want. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint