COHERENT manpages

This page displays the COHERENT manpage for portability [Definition].

List of available manpages
Index


portability -- Definition

Portability  means that  code  can be  recompiled and  run under  different
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:

-> 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.

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

-> 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 <ctrl-Z> instead of EOF ensures that that code can run
   only under operating systems that recognize this magic character.

-> Always use manifest constants, such as EOF, and make full use of #define
   statements.

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

-> Declare  everything  explicitly.   In  particular,  be sure  to  declare
   functions as void if they do  not return a value; this avoids unforeseen
   problems with undefined return values.

-> 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  addresses  relative  to  the  data  segment.   On  some  machines,
   character  pointers  are of  a  different size  or  structure than  word
   pointers.

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

-> Keep test  scripts, preferably at  the function level.   That is, follow
   each function with an

       #ifdef TEST

   section  that will  exercise that function.   Running these  can rapidly
   isolate portability problems.

-> Place plenty of

       #assert

   statements  in  your  programs.  These  can  often  pick up  portability
   problems.

See Also

header files,
pointer,
Programming COHERENT,
void