C/C++ Programmer's Guide (G06.27+, H06.03+)

Table Of Contents
Compiling, Binding, and Accelerating TNS C++
Programs
HP C/C++ Programmer’s Guide for NonStop Systems429301-010
15-6
Working in the Guardian Environment
Cprep and Cfront both send error and warning messages to stderr. The default
location for stderr is the terminal. You can assign stderr to a specific file and
collect all Cprep and Cfront error and warning messages there.
To send error and warning messages to a file, assign stderr to the desired file
name prior to invoking Cprep. You assign stderr to a file name:
ASSIGN STDERR, file-name
To return to the default location, enter:
CLEAR ASSIGN STDERR
Example
In this example, the C++ source file progcp is input to Cprep. An intermediate file,
intfile1, is created by Cprep for later use by Cfront. The SSV pragma SSV0 causes
any header files in progcp to be searched for in the subvolume hdrvol; that is, Cprep
looks in subvolume hdrvol for a file named hdrh if progcp contains the statement
#include "hdrh."
CPREP/IN progcp, OUT intfile1/define __cplusplus, SSV0 "hdrvol"
C++ Translator Cfront
Cfront generates code for the TNS C compiler. In so doing, Cfront performs these
functions:
Always generates function prototypes
Uses the NOWIDE or RUNNABLE pragmas, if they were specified on the Cprep run
command line or in the C++ source
Generates these pragmas: C_PLUS_PLUS, C_PLUS_PLUS_STMT, NOWARN(134,
135), and SEARCH
Produces a C source file that serves as the input to the TNS C compiler
Pragmas Generated by Cfront
Cfront generates these pragmas: C_PLUS_PLUS, C_PLUS_PLUS_STMT,
NOWARN(134, 135), and SEARCH. Each of these pragmas is explained below.
Pragma Use
C_PLUS_PLUS notifies the TNS C compiler that this object file is derived from
C++ source code.
C_PLUS_PLUS_STMT identifies a C++ statement to the TNS C compiler. This pragma
causes the next C statement to be identified as the start of
generated C code for the C++ statement to be found in the file and
at the line number specified by the latest #line directive. This
information is used for symbolic debugging.