/SAVE compiler option


By default, local variables are stored dynamically on the stack. Space for dynamic variables is reserved on entry to a program unit; the space is freed, and all data values are lost on RETURN. The alternative is to store variables statically. Static variables maintain their values until execution terminates. The following types of variables will automatically be static:

  • Any variable that appears in a SAVE statement.

  • Any variable in a program unit that contains a blank SAVE statement.

  • Any variable that appears in a DATA statement.

  • Any COMMON block variable.

  • Any variable that is initialised, e.g. INTEGER::I = 1

All other variables will be made static if the /SAVE option is used. However, it is better programming practise to use SAVE state ments in program units where static storage is required, rather than relying on the use of a /SAVE compiler option.



Copyright © 1999-2023 Silverfrost Limited