HP 3000 Manuals

Recommendations for Using Include Files [ HP C/iX Reference Manual ] MPE/iX 5.0 Documentation


HP C/iX Reference Manual

Recommendations for Using Include Files 

If you have include files or source files spread throughout your
file system, you may want to become familiar with the following
recommendations for arranging include files in a flexible and consistent
manner.  However, if you keep all source and include files in a single
group and account on your system, the recommendations listed below may
not be useful to you.

There is no best way to arrange include files on a system but there are
practices to follow that make the use of include files simple and
efficient for most cases.  Include file searching for standard files
enclosed by angle brackets is fully described in chapter 8.  The
following recommendations are for include file names enclosed by double
quotes.

   *   Put include files in the same group and account as the source file
       with which they are associated.  This is the default search place
       for files that are not fully qualified and for qualified files
       that are not found in the first try.

   *   If you have standard files to be shared by source files in the
       same account but in different groups, put them in the H group of
       the source file's account.  Be aware that if source files specify
       file.h for these standard files, a FILE equation command
       is required to open any file other than file.h.srcacct.
       Consequently, this is the first file opened by the preprocessor
       because the account of the source file is implied before any -I
       options are examined.

   *   Use the -I option to tell the preprocessor where to find include
       files that are not in the exact group or the H group of the source
       file's account.  Qualify the -I option with group and account if
       you want searches in the account of the source file.  Omit the
       account specification only if you want searches made in the
       account of the current user, as you might when using job files
       that log on in other accounts.

   *   If you want to override the defaults for a single include file, or
       small subset of include files, use MPE/iX's FILE command to equate
       the file that is opened by the preprocessor to the file that you
       want to use.  Use the rules for include file searching to
       determine exactly what file the preprocessor opens and use that
       fully qualified name in the file equation.

Examples 

For the source file FILE1.MYGRP.OURACCT that needs a special header file
called MYDEFS, put MYDEFS in MYGRP.OURACCT and use:

       #include "MYDEFS"

in FILE1.MYGRP.OURACCT . The name MYDEFS.H in the include statement also
works, as does putting the MYDEFS file in H.OURACCT, but neither of those
choices reflects the intended use of the file MYDEFS.

If you want to substitute the file FIXDEFS for MYDEFS when compiling
FILE1.MYGRP.OURACCT in the above example, use the file equation:

       :FILE MYDEFS.MYGRP.OURACCT = FIXDEFS

It is important to note that a fully qualified formal designator is
required for the file to be successfully equated, as the preprocessor
builds a fully qualified file name before attempting an open.  The
exception to this rule is when the preprocessor opens a file using a -I
option that only specifies a group.  If a file equation and this type of
-I option are both needed to find a file, it is likely that the file
could be moved to a more effective location and a simpler searching
strategy used.

For the source file FILE2.MYGRP.OURACCT that needs a general header file
called OURDEFS, put OURDEFS in H.OURACCT and use:

       #include "OURDEFS.H"

or use:

       #include "OURDEFS"

in FILE2.MYGRP.OURACCT . The first form is more restrictive because it
finds the file before the -I options are examined.  The second allows a
-Igrp.acct specification to be used to include a different set of header
files.

In summary, the best overall strategy is to locate your include files in
the appropriate groups and accounts and use FILE commands and the -I
compiler option to handle exceptional cases.



MPE/iX 5.0 Documentation