(* func)(fred, bert)

Doug Gwyn gwyn at smoke.BRL.MIL
Fri Nov 24 03:35:25 AEST 1989


In article <1736 at l.cc.purdue.edu> cik at l.cc.purdue.edu (Herman Rubin) writes:
>To get 100% portable code, it is necessary to be absolutely sure that
>the same results occur in all installations.  For C, this would mean
>that all arithmetic be integer arithmetic, ...  Furthermore,
>unsigned arithmetic must be used, as there is no guaranteed way to get
>the signed numbers correct (except possibly by casting in exactly the
>right manner).
>Boolean operations could still be used, but shifts would require the
>truncation to be explicit, and sign-propagation shifts would require
>the appropriate corrections to be explicit.  No floating point would
>be usable.

NO!  You are trying to come up with rules that guarantee that ANY
code following them WILL work portably.  However, in practice all
that a portable C programmer needs to do is to stay within the bounds
of what is guaranteed by the language specs to work properly.  That
is a MUCH larger domain than your rules imply.

And in any case you didn't address the issue we were discussing,
the rule for which would be "use types properly".  Certainly,
deliberate violation of C's type compatibility rules is just
asking for portability problems.



More information about the Comp.lang.c mailing list