Skip to main content

IAR Embedded Workbench for Arm 9.70.x

‑‑do_explicit_zero_opt_in_named_sections

In this section:
Syntax
‑‑do_explicit_zero_opt_in_named_sections
Description

By default, the compiler treats static initialization of variables explicitly and implicitly initialized to zero the same, except for variables which are to be placed in user-named sections. For these variables, an explicit zero initialization is treated as a copy initialization, that is the same way as variables statically initialized to something other than zero.

Use this option to disable the exception for variables in user-named sections, and thus treat explicit initializations to zero as zero initializations, not copy initializations.

Example
int var1;                // Implicit zero init -> zero inited
int var2 = 0;            // Explicit zero init -> zero inited
int var3 = 7;            // Not zero init      -> copy inited
int var4 @ "MYDATA";     // Implicit zero init -> zero inited
int var5 @ "MYDATA" = 0; // Explicit zero init -> copy inited
                         // If option specified, then zero inited
int var6 @ "MYDATA" = 7; // Not zero init      -> copy inited

Caution

To set this option, use Project>Options>C/C++ Compiler>Extra Options.