

portability           Technical Information           portability




Portability means that code  can be recompiled and run under dif-
ferent  computing  environments  without modification.   Although
true portability  is an ideal  that is difficult  to realize, you
can take a number of practical  steps to ensure that your code is
portable:

   11.
     Do not  assume that an  integer and a pointer  have the same
     size.   Remember that  undeclared functions  are  assumed to
     return an int.  If  a function returns a pointer, declare it
     so.

   22.
     Do not  write routines that depend on  a particular order of
     code  evaluation, particular  byte  ordering, or  particular
     length of data types.

   33.
     Do  not write  routines that  play  tricks with  a machine's
     ``magic  characters''; for example,  writing a  routine that
     depends on a file's  ending with <ccttrrll-ZZ> instead of EEOOFF en-
     sures that  that code can  run only under  operating systems
     that recognize this magic character.

   44.
     Always use  manifest constants, such  as EEOOFF, and  make full
     use of #ddeeffiinnee statements.

   55.
     Use header files  to hold all machine-dependent declarations
     and definitions.

   66.
     Declare  everything explicitly.  In  particular, be  sure to
     declare functions  as vvooiidd  if they  do not return  a value;
     this  avoids  unforeseen   problems  with  undefined  return
     values.

   77.
     Do not assume that  integers and pointers have the same size
     or  even the  same kind  of structure.   Do not  assume that
     pointers are  all the  same or  can point anywhere.   On the
     i8086,  in SMALL  model a  pointer  to a  function addresses
     relative to the code  segment, whereas a pointer to data ad-
     dresses  relative to  the data  segment.  On  some machines,
     character pointers are of a different size or structure than
     word pointers.

   88.
     The  constant NULL  is defined as  being different  from any
     valid pointer.  Use it and nothing else for that purpose.





COHERENT Lexicon                                           Page 1




portability           Technical Information           portability



***** See Also *****

header file, pointer, technical information, void






















































COHERENT Lexicon                                           Page 2


