-OnCstVar: Disable CONST Variable by Constant Replacement

Group

OPTIMIZATIONS

Scope

Compilation Unit

Syntax
  -OnCstVar
  
  
Arguments

None

Default

None

Defines

None

Pragmas

None

Description

This option provides you with a way to switch OFF the replacement of CONST variable by the constant value.

Example
  const int MyConst = 5;
  
  
  int i;
  
  
  void foo(void) {
  
  
    i = MyConst;
  
  
  }
  
  

If the -OnStVar option is not set, the compiler replaces each occurrence of MyConst with its constant value 5; that is i = MyConst is transformed into i = 5;. The Memory or ROM needed for the MyConst constant variable is optimized as well. With the -OnCstVar option set, this optimization is avoided. This is logical only if you want unoptimized code.