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

Example
In this example, the intermediate file intfile2, which was previously created by Cfront, is now input
to the TNS C compiler. The TNS C compiler produces the TNS object file progo that you can now
use to bind together with other TNS object files to produce an executable TNS object file for the
C++ program.
C/ IN intfile2, OUT $s.#hold/progo
File Formats
The input to Cprep is a C++ source file of a form acceptable to the TNS C run-time library:
EDIT disk files, which are file type 101
C disk files, which are odd-unstructured files and are file type 180
Processes
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 these run commands:
Working in the Guardian Environment 279