Initialization of Composite Elements

By default, composite elements used as variables or parameters are initialized in the generated code as follows:

The code for these initializations can become very long, especially for arrays and matrices with variant size and a large max. size. This is a challenge for compilers, code comparison tools, etc. In the worst case, the initializations can become so long that the ECCOClosedEmbedded Code Creator and Optimizer aborts with an out-of-memory error.

To solve this problem, ASCETV6.4.10 contains a target option, Generating Sparse Arrays, that optimizes initialization code generation for sparse arrays and matrices of scalar or enumeration type. This option is available for experimental targets (RP targets, PC target) and ASCET‑SE targets (ANSI-C target, EHOOKS target, microcontroller targets).

When Generating Sparse Arrays is activated, you can define a threshold number, which is interpreted as the minimum percentage of 0 values among the init values of all array/matrix elements, or values of a characteristic line/map. Initialization code is generated as follows:

Note

Some compilers cannot process the optimized initialization code generated with activated Generating Sparse Arrays. The information whether or not a particular compiler supports the optimized initialization code is given in the ASCET options window, External Tools\Compiler\<compiler name> node, Supports Generation of Sparse Arrays option.

See also

Examples: Initialization of Composite Elements

Array

Matrix

Variant Size for Arrays and Matrices

ASCET Options – Targets Node

Characteristic Lines and Maps