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

15 Compiling, Binding, and Accelerating TNS C++
Programs
Working in the Guardian Environment
To create an executable TNS C++ program in the Guardian environment:
1. Run the C preprocessor Cprep
2. Run the C++ translator Cfront
3. Run the C compiler
4. Run the Binder
5. Run the Accelerator or Object Code Accelerator (OCA) (optional)
This chapter describes each compilation step, including the purpose of the compilation, the output
from the compilation, and the syntax description for the compilation run command. This section
also contains an example that shows you how to compile a simple TNS C++ program.
You can use a separate run command for each of the C++ compilation steps, as described in this
section and shown in the compilation example, or you can use a TACL macro to consolidate these
compilation steps.
If you use a TACL macro to drive the C++ compilation, you still need to understand what is needed
for each compilation step, what is accomplished by each compilation step, and what is the possible
output from each compilation step. This section provides you with this information.
After compiling your C++ program, you run the Binder to create an executable C++ object file.
This section describes a sample set of Binder commands that you can use to bind your
C++ programs.
You can use the Accelerator or OCA to make programs more efficient on native systems. The same
rules that apply to accelerating C programs apply to accelerating C++ programs. If you want to
accelerate your program, see the Accelerator Manual or Object Code Accelerator (OCA) Manual
for the necessary information.
Cfront is shipped with a simple TACL macro, named cplus, that allows you to consolidate the
compilation process. The cplus macro is also provided here for your information:
?tacl macro
==This is a general purpose macro to use with Cfront on an HP
System. You can add any preprocessor options such as
== SSV pragmas to this macro.
==
purge %1%1, %1%2, %1%o, %1%L
#output Preprocessing %1%c
cprep /in %1%c, out %1%1/ define __cplusplus, ssv0 "$system.system"
[#if NOT(:_COMPLETION:COMPLETIONCODE>1) |THEN|
#output Finished Preprocessor step. Starting CFRONT.
cfront /in %1%1, out %1%2/
[#if NOT(:_COMPLETION:COMPLETIONCODE>1) |THEN|
#output Finished CFRONT step. Starting C.
c /in %1%2, out %1%L/%1%o; suppress
[#if NOT(:_COMPLETION:COMPLETIONCODE>1) |THEN|
#output Finished C step. Purging intermediate files.
purge %1%1, %1%2, %1%L
]
]
]
If the C++ files Cprep, Cfront, and the C compiler are installed on $SYSTEM, the TACL macro
cplus should be in $SYSTEM.ZCFRONT.
Working in the Guardian Environment 273