Keil Logo

INIT Compiler Directive

Abbreviation

IN

Arguments

None.

Default

INIT

µVision

This directive may not be specified on the command line.

Description

The INIT directive specifies that declared variables are initialized with zero (0) at the startup (reset) of the program. This is the default for the C Programming Language.

Embedded systems with non-volatile memory may require that variables are not cleared to zero at startup. The INIT directive may be used with the NOINIT directive to switch back and forth between variables which should be initialized and those which should not.

Note:

  • Automatic (local) variables which are declared inside a function are stack-based and are never initialized at startup time. It is the resposiblity of the programmer to supply an initial value to such variables if required.
See Also

NOINIT

Example
#pragma NOINIT
char states[100];     /* Uninitialized Variable */

#pragma INIT
char array[100];      /* Initialized Variable */
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.