HP 3000 Manuals

Ch 7. Preprocessing Directives [ HP C/iX Reference Manual ] MPE/iX 5.0 Documentation


HP C/iX Reference Manual

Chapter 7  Preprocessing Directives 

Preprocessing directives function as compiler control lines.  They enable
you to direct the compiler to perform certain actions on the source file.
You can use the preprocessing directives to make a number of textual
changes in the source before it is syntactically and semantically
analyzed and translated.  Since preprocessing occurs conceptually before
the compilation process, there is generally no relationship between the
syntax of a translation unit and preprocessing directives.  There are
some restrictions on where #pragma directives may appear within a
translation unit.  Refer to chapter 8 for details.

Syntax 

     preprocessor-directive ::=
         include-directive newline 
         macro-directive newline 
         conditional-directive newline 
         line-directive newline 
         error-directive newline 
         pragma-directive newline 

Description 

The preprocessing directives control the following general functions:

   1.  Source File Inclusion 

       You can direct the compiler to include other source files at a
       given point.  This is normally used to centralize declarations or
       to access standard system headers such as stdio.h.sys.

   2.  Macro Replacement 

       You can direct the compiler to replace token sequences with other
       token sequences.  This is frequently used to define names for
       constants rather than hard coding them into the source files.

   3.  Conditional Inclusion 

       You can direct the compiler to check values and flags, and compile
       or skip source code based on the outcome of a comparison.  This
       feature is useful in writing a single source that will be used for
       several different computers.

   4.  Line Control 

       You can direct the compiler to increment subsequent lines from a
       number specified in a control line.

   5.  Pragma Directive 

       Pragmas are implementation-dependent instructions that are
       directed to the compiler.  Because they are system dependent, they
       are not portable.

All preprocessing directives begin with a pound sign (#) as the first
character in a line of a source file.  The # character is followed by any
number of spaces and horizontal tab characters and the preprocessing
directive.  The directive is terminated by a new-line character.  You can
continue directives, as well as normal source lines, over several lines
by ending lines that are to be continued with a backslash (\).


NOTE In ANSI mode, white space may precede the # character in preprocessing directives.
Comments in the source file that are not passed by default through the preprocessor are replaced with a single white-space character. Examples include-directive: #include <stdio.h> macro-directive: #define MAC x+y conditional-directive: #ifdef MAC line-directive: #line 5 "myfile" pragma-directive: #pragma INTRINSIC func


MPE/iX 5.0 Documentation