Reference of Pragmas

In general, no change in the source code is necessary to use Testwell CTC++. In some use cases, specific #pragma instructions can be used to customize the behavior in detail.

When the source file is instrumented, the pragmas expand to calls to the Testwell CTC++ run-time library and are executed in the normal flow of the program.

When the source file is not instrumented, these pragmas appear to the compiler as "unknown pragmas", hence a warning is given, but the file are still compiled.

#pragma CTC INIT
The INIT pragma maps to a ctc_init() call. It sets to zero all measurement data in memory of the instrumented program. The possible measurement data collected so far will be lost. The nullifying will be done on the counters of the module, where the pragma resides, and also on the counters of the other modules that the run-time system has seen so far (their instrumented code has been visited). Later, new modules may become known to the run-time library and they start their counters from zero anyway. This pragma must be inside a function in the same position as a statement.
#pragma CTC APPEND
The APPEND pragma maps to a ctc_append_all() call. It writes the coverage data to data file(s). The behavior is the same as the default output at the program's end. The measurement data in main memory is a set of file-specific data areas. Each such data area is a set of counter vectors. Testwell CTC++ writes one such vector to a data file in one elementary write operation, and once completed, the vector is zeroed. This ensures that the same measurement data is not appended twice. This pragma must be inside a function in the same position as a statement. The configuration parameter EMBED_FUNCTION_NAME is an alternate way to trigger the coverage data writing. It has the benefit that the actual source file need not be edited for this purpose.
#pragma CTC QUIT
The QUIT pragma maps to a ctc_quit() call. It ends the instrumented program execution without writing the measurement data to a data file and calls exit(0). This pragma must be inside a function in the same position as a statement.
#pragma CTC TESTCASE testcasename
The TESTCASE pragma maps to a ctc_set_testcase("testcasename") call. With the test case concept, coverage data is separated by test case to different data files. This pragma must be inside a function in the same position as a statement.
The pair #pragma CTC SKIP and #pragma CTC ENDSKIP
The part of the source code surrounded by these pragmas is skipped during instrumentation. They are meant to be used outside functions. If used inside a function, no statement coverage is calculated for this function. Inside macro definitions, the string statements "CTC SKIP"; and "CTC ENDSKIP"; can be used as an alternative.
#pragma CTC COUNT counter name
A user can define their own counters with this pragma. For example, it can be measured how often a function was called from a certain location by inserting this pragma just before the call. In the reports, this counter is shown as User counter: counter name.
#pragma CTC ANNOTATION description
Annotations are special comments in the source code to be shown in the coverage reports of Testwell CTC++. Missing coverage can be explained, for example.