Neuron c storage classes – Echelon Mini FX User Manual
Page 80
Mini FX User's Guide
67
Neuron C Storage Classes
If no class is specified for a declaration 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, a
when-task, or an interrupt-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. In addition, extern references can be used to
publish a symbol and allow for linking with other object files.
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, it is set to 0.
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.
The Neuron C language does not permit the use of const with auto.
• 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:
• network begins a network variable declaration. See Chapter 3, How Devices
Communicate Using Network Variables, of the Neuron C Programmer’s Guide for
more details.
• uninit when combined with the eeprom keyword (see below), specifies that the
EEPROM variable is not initialized or altered on program load or reload over the
network.
The following Neuron C keywords allow you to direct portions of application code and
data to specific memory sections.
• eeprom
• far
• offchip (only on Neuron Chips and Smart Transceivers with external memory)
• onchip
These keywords are particularly useful on the Neuron 3150 Chip and 3150 Smart
Transceivers, since a majority of the address space for these parts is mapped off chip.
See Using Neuron Chip Memory in Chapter 8 of the Neuron C Programmer’s Guide for a
more detailed description of memory usage and the use of these keywords.