C++ Producer Guide

March 1998

next section previous section current document TenDRA home page document index


2.1.1 - Compilation scheme
2.1.2 - Producer options

2.1. Invocation

In this section it is described how the C++ to TDF producer, tcpplus, fits into the overall compilation scheme controlled by the TenDRA compiler front-end, tcc, or the TenDRA checker front-end, tchk. While it is possible to use tcpplus as a stand-alone program, it is recommended that it should be invoked via tcc or tchk. The tcc users' guide should be consulted for more details.

tcc and tchk require the -Yc++ command-line option in order to enable their C++ capabilities. Files with a .C suffix are recognised as C++ source files and passed to tcpplus for processing (see below). It is possible to change the suffix used for C++ source files; for example -sC:cc causes .cc files to be recognised as C++ source files. An interesting variation is -sC:c which causes C source files to be processed by the C++ producer. Similarly .I files are recognised as preprocessed C++ source files and .K files are recognised as C++ spec files.

Most of the command-line option handling for tcpplus is done by tcc and tchk, however it is possible to pass the option opt directly to tcpplus using the option -Wx,opt to tcc or tchk. Similarly -Wg,opt and -WS,opt can be used to pass options to the C++ preprocessor and the C++ spec linker (both of which are actually tcpplus invoked with different options) respectively.


2.1.1. Compilation scheme

The overall compilation scheme controlled by tcc, as it relates to the C++ producer, can be represented as follows:

compilation scheme
Each C++ source file, a.C say, is processed using tcpplus to give an output TDF capsule, a.j, which is passed to the installer phase of tcc. The capsule is linked with any target dependent token definition libraries, translated to assembler and assembled to give a binary object file, a.o. The various object files comprising the program are then linked with the system libraries to give a final executable, a.out.

In addition to this main compilation scheme, tcpplus can additionally be made to output a C++ spec file for each C++ source file, a.K say. These C++ spec files can be linked, using tcpplus in its spec linker mode, to give an additional TDF capsule, x.j say, and a combined C++ spec file, x.K. The main purpose of this C++ spec linking is to perform intermodule checks on the program, however in the course of this checking exported templates which are defined in one module and used in another are instantiated. This extra code is output to x.j, which is then installed and linked in the normal way.

Note that intermodule checks, and hence intermodule template instantiations, are only performed if the -im option is passed to tcc.

The TenDRA checker, tchk, is similar to tcc except that it disables TDF output and has intermodule analysis enabled by default.


2.1.2. Producer options

The general form for the invocation of tcpplus is as follows:

	tcpplus [ options ] [ input-file ] .... [ output-file ]
The output file can alternatively be specified using the -o option. If no output file is given, or the output file is -, the standard output is used. In general there can be any number of input files. If no input file is given, or the input file is -, the standard input is used.

tcpplus has three modes which determine the form of its input and output files. The default mode is compilation, in which a single input C++ source file is translated into an output TDF capsule. In preprocessing mode, specified using the -E option, a single input C++ source file is preprocessed into an output C++ source file. Note that the preprocessor is built into tcpplus, rather than, as with most other compilers, being a separate program. The final mode is C++ spec linking, specified using the -S option. Any number of C++ spec input files are linked and any code generated as a result (for example, template instantiations) is written to the output TDF capsule.

In either compilation or spec linking mode, a C++ spec output file can be generated, in addition to the TDF capsule, using the -s option. In any mode a symbol table dump output file can generated using the -d option.

Command-line options can appear in any order and can be interspersed with the input and output files, except following a -- option. All the multi-part options can be given either as one or two command-line arguments, so that -Idirectory and -I directory are equivalent. The recognised options are as follows:

-Apredicate(tokens)
Asserts that the given predicate is true, that is to say:
	#assert predicate ( tokens )
The special case -A- undefines all the built-in predicates (of which there are none). Use of this option automatically enables support for the #assert and #unassert directives.

-Dmacro
-Dmacro=tokens
Defines the given macro to be 1 in the first case, or the given sequence of preprocessing tokens in the second case, that is to say:
	#define macro 1
	#define macro tokens
respectively. In fact -D and -U options to tcc are not passed as -D and -U options to tcpplus. Instead a start-up file containing the equivalent #define and #undef directives is used.

-E
Enables preprocessing mode in which the input C++ source file is preprocessed into the output file.

-Ffile
Causes a list of command-line options to be read from file. Other than empty lines and lines beginning with #, each line in the file is treated as if it had been specified as a separate command-line option.

-H
Enables verbose inclusion mode in which warnings are printed at the start and end of each included source file.

-Idirectory
Adds the given directory to the list searched for included source files. No such directories are built into the producer by default.

-Nname:directory
This is identical to -Idirectory except that it also associates the given identifier with the directory. The directory name can be used to specify a compilation profile to be used on files included from this directory.

-S
Enables C++ spec linker mode, in which any number of C++ spec input files are linked together.

-Umacro
Undefines the given macro, that is to say:
	#undef macro
The special case -U- undefines all the built-in macros. These may be described as follows:
	#define __FILE__		(current file)
	#define __LINE__		(current line)
	#define __TIME__		(current time)
	#define __DATE__		(current date)
	#define __STDC__		1
	#define __STDC_VERSION__	199409L
	#define __cplusplus		199711L
The actual value of __cplusplus gives the date of the draft ISO C++ standard on which the current version of the producer is based. The value given above gives the expected date of the final C++ standard.

-V
Causes the name of each function to be printed to the standard output as it is compiled.

-Woption
Sets the given compiler option to give a warning, that is to say:
	#pragma TenDRA option "option" warning
The special case -Wall enables a wide range of warnings.

-X
Disables exception handling. The current implementation can be a large run-time overhead if not required. The effect of linking any module compiled with this option with a module which throws an exception is undefined. This is equivalent to -j-e.

-a
Causes complete program analysis to be applied. That is to say it is assumed that no other translation units need to be linked in order for the program to execute.

-c
Disables TDF output. The output file will still be a valid TDF capsule, but it will contain no information. This is equivalent to -j-c.

-dopt=dump-file
Specifies the given file as a symbol table dump output file. opt will be a series of characters describing the information to be dumped, as follows:

Key Description
a equivalent to ehlmu
c dump string literals
e dump error messages
h dump header information
k dump keyword identifiers
l dump local variables
m dump macro identifiers
s dump scope information
u dump identifier usage information

Note that these correspond to the tcc -sym options.

-efile
Specifies the given file as an end-up file. This is equivalent to adding:
	#include "file"
at the end of the input source file. More than one end-up file may be given; they are processed in the order given.

-ffile
Specifies the given file as a start-up file. This is equivalent to adding:
	#include "file"
at the start of the input source file. More than one start-up file may be given; they are processed in the order given.

-g
Specifies that the output TDF capsule should also contain information to allow for the generation of run-time debugging directives. This is equivalent to -jg.

-h
Causes a full list of command-line options to be printed. This includes a number not documented here which are unlikely to prove useful to the normal user.

-jopt
Sets the TDF output options given by opt. This consists of a sequence of characters describing the options to be enabled or disabled. By default, or following a +, the options are enabled; following a - they are disabled. The available options are as follows:

Key Default Description
a off output external names for local objects
b off work round old installer bugs
c on output TDF capsule
d off output termination function
e on output exceptions
f on mangle template function signatures
g off output debugging information
i off output dynamic initialisers as a function
n on mangle object names
o off order class data members by access
p on output partial destructors
r on output run-time type information
s on output shared string literals
t off output token declarations
u on output unused static variables
v off output local virtual function tables

-mopt
Sets the error formatting options given by opt. This consists of a sequence of characters describing the options to be enabled or disabled. By default, or following a +, the options are enabled; following a - they are disabled. The available options are as follows:

Key Default Description
c off show source code with error
e off show error name
f on reliable fseek function
g off record statement locations
i on reliable stat function
k off enable C++ spec output
l off output full error location
s on output ISO section number
t off use typedef names in errors
w off disable warnings
z off continue after error

-nport-table
Specifies that the given portability table should be used to specify the basic configuration parameters.

-ooutput-file
Gives an alternative method of specifying the output file.

-q
Causes the program to quit immediately without processing its input files. This is useful primarily in version and command-line option queries.

-sspec-file
Specifies the given file as a C++ spec output file.

-t
Specifies that token declarations should be included in the output TDF capsule. While these are strictly unnecessary, they help when pretty-printing the output. This is equivalent to -jt.

-u
The form:
	tcpplus -u name .... name
can be used to print the unmangled forms of a list of mangled identifier names to the standard output.

-v
Causes the C++ producer version number, plus information on the versions of C++ and TDF supported, to be printed to the standard error.

-w
Disables all warning messages. This is equivalent to -mw.

-z
Forces an output file to be created even if compilation errors occur. The effect of installing a TDF capsule produced using this option is undefined. This is equivalent to -mz.

--
Marks the last option. Any subsequent arguments are interpreted as input and output files even if they resemble command-line options.


Part of the TenDRA Web.
Crown Copyright © 1998.