8. Configuration for initialisers
8.1. Initialisation of compound types
Many older C dialects do not allow the initialisation of automatic variables of compound type. Thus, for example:
void f () { struct { int a; int b; } x = { 3, 2 }; }
would not be allowed by some older compilers, although by default tdfc2 does not raise any errors since the code is legal according to the ISO C standard. The checker's behaviour may be changed using:
#pragma TenDRA initialization of struct/union (auto) permit
where permit is allow
, warning
or disallow
. This feature is particularly useful when developing a program which is intended to be compiled with a compiler which does not support automatic compound initialisations.
8.2. Variable initialisation
The ISO C standard (Section 6.5.7) states that all expressions in an initialiser for an object that has static storage duration or in an initialiser-list for an object that has aggregate or union type shall be constant expressions. The pragma:
#pragma TenDRA variable initialization permit
may be used to allow non-constant initialisers if permit is replaced by allow
. The other option for permit is disallow
which restores the default behaviour of flagging non-constant initialisers for objects of static storage duration as errors.