C/C++ Programmer's Guide (G06.25+)

Compiling, Binding, and Accelerating TNS C++
Programs
HP C/C++ Programmer’s Guide for NonStop Systems429301-008
15-10
Working in the Guardian Environment
Terminals
The input to Cprep is usually an EDIT file. The output of Cprep is a C++ source file,
which is referred to in this section as an intermediate file. This intermediate C++ source
file is by default a type 101 file and is used as the input to Cfront.
The output of Cfront is a C source file, which is also referred to in this section as an
intermediate file. This intermediate C source file is by default a type 180 file and is
used as the input to the TNS C compiler.
If you want your intermediate file to be a file type other than the default file type, create
an empty file of the desired type before running Cprep or Cfront. The file you create
must be acceptable to the TNS C run-time library.
If an intermediate file exists prior to the invocation of Cprep or Cfront, the output is
appended to the end of that file.
If you do not specify an output file to Cprep or Cfront, the output will go to the terminal.
Compiling a Sample C++ Program
This example shows a C++ source program and the run commands necessary to
compile it. The C++ source program comprises a single compilation module, so you
can compile it with the RUNNABLE pragma specified. The compilation will produce an
executable C++ TNS object file, so you do not have to run the Binder. Here is the
C++ source program:
#pragma runnable
#include "iostream.h" // Cprep truncates to iostreah
main()
cout << "Hello World\n";
}
This example assumes:
The C++ source program is located in a file named progcp
The file named intfile1 is the intermediate file that will contain the C++ source
code created by Cprep
The file named intfile2 is the intermediate file that will contain the C source
code created by Cfront
Before compiling this program, purge any existing intermediate files:
purge intfile1
purge intfile2
To compile this program, enter the following run commands:
cprep/in progcp, out intfile1/define __cplusplus, &
SSV0 "$system.system"