Source Code Variants
When source code is preprocessed differently, variants arise. These variants and their coverage are reported separately. For convenience, a merged version can be generated.
Preprocessor directives like #if or #ifdef create
variants, if source code is active in one compilation and inactive in another one. Macro
code from #define statements can also lead to variants recognized by
Testwell CTC++.
Example: Source file with conditionally active functions
basic_functions.c contains two functions,
special_linux and special_win, each of them
only active when compiled for the respective operating system. By default, variants
are reported separately, with numbers (1), (2), and so on. Each variant has its own
coverage counters.

Merging of variants
- see full coverage for functions not affected by preprocessing differences,
- get a combined impression about coverage for affected functions,
- avoid multiplied impact of one source file with variants on the total figures.
With two options of ctcreport, you can merge variants:
-merge-variants, leading to one representation for every source
file, and -merge-and-keep-variants, showing both the variants and
the merged result.
If a function is identical in all file variants it is present in, all coverage data is simply combined. For example, counters are added up.
If a function has preprocessing differences itself, ctcreport calculates merged figures for all coverage measures. The purpose is a good enough impression when preprocessing differences are small - if the nature of a function is completely changed, the results become useless.
In the merged representation of a function, lines are marked with a grey bar if they are both active and inactive in the function's variants. Instrumentation probes are marked if they are different in the variants.
Example: Source code view of two variants and their merged representation
In function do_stuff, the macro MAGIC_CONSTANT
leads to two different probes for line 22. The associated counters are all present
and not added up. The three statements in if-branch are considered
equal, hence they are counted as executed in the merged result.
Function do_more_stuff contains conditionally compiled code. A code
line being active and executed in at least one variant is considered active and
executed in the merged result. Lines 31, 32 and 34 are marked as they are also
inactive in one variant.
