Neuron c storage classes – Echelon Neuron C User Manual

Page 18

Advertising
background image

6

Overview

Neuron C Storage Classes

If no class is specified and the declaration is at file scope, the data or function is

global.

File scope

is that part of a Neuron C program that is not contained within

a function or a task. Global data (including all data declared with the static

keyword) is present throughout the entire execution of the program, starting

from the point where the symbol was declared. Declarations using extern
references can be used to provide forward references to variables, and function

prototypes must be declared to provide forward references to functions.
Upon power-up or reset of a Neuron Chip or Smart Transceiver, the global data
in RAM is initialized to its initial-value expression, if present, otherwise to zero

(variables declared with the eeprom or config class, as well as configuration
properties declared with the config_prop or cp_family keywords, are only

initialized when the application image is first loaded).
Neuron C supports the following ANSI C storage classes and type qualifiers:

auto

Declares a variable of local scope. Typically, this would be within a

function body. This is the default storage class within a local scope

and the keyword is normally not specified. Variables of auto scope
that are not also static are not initialized upon entry to the local

scope. The value of the variable is not preserved once program

execution leaves the scope.

const

Declares a value that cannot be modified by the application program.

Affects self-documentation (SD) data generated by the Neuron C

compiler when used in conjunction with the declaration of CP families
or configuration network variables.

extern

Declares a data item or function that is defined in another module, in
a library, or in the system image.

static

Declares a data item or function which is

not

to be made available to

other modules at link time. Furthermore, if the data item is local to a
function or to a when task, the data value is to be preserved between

invocations, and is not made available to other functions at compile

time.

In addition to the ANSI C storage classes, Neuron C provides the following

classes and class modifiers:
config

Can be combined only with an input network variable declaration. A
config network variable is used for application configuration. It is

equivalent to const eeprom. Such a network variable is initialized
only when the application image is first loaded. The config class is

obsolete and is included only for legacy applications. The Neuron C

compiler does not generate self-documentation data for config-class
network variables. New applications should use the configuration

network variable syntax described Chapter 4,

Using Configuration

Properties to Configure Device Behavior

, on page 83.

network

Begins a network variable declaration. See Chapter 3,

How Devices

Communicate Using Network Variables

, on page 43, for more details.

system

Used in Neuron C solely to access the Neuron firmware function
library. Do not use this keyword for data or function declarations.

Advertising