Enumerations, Floating point variables – Echelon FTXL User Manual
Page 78
![background image](/manuals/735717/78/background.png)
66
Using the LonTalk Interface Developer Utility
LON_SET_ATTRIBUTE(var, LON_ALPHA, alpha_flag);
These macros are defined in the FtxlTypes.h file.
Enumerations
The LonTalk Interface Developer utility does not produce enumerations. FTXL
requires an enumeration to be of size byte. The ANSI C standard requires that
an enumeration be an int, which is larger than one byte for many platforms.
An FTXL enumeration uses the LON_ENUM_BEGIN and LON_ENUM_END
macros. For many compilers, these macros can be defined to generate native
enumerations:
#define LON_ENUM_BEGIN(name) enum
#define LON_ENUM_END(name)
name
Some compilers support a colon notation to define the enumeration’s underlying
type:
#define LON_ENUM_BEGIN(name) enum : signed char
#define LON_ENUM_END(name)
When your program refers to an enumerated type in a structure or union, it
should not use the enumeration’s name, but should use the LON_ENUM_*
macros.
For those compilers that support byte-sized enumerations, it can be defined as:
#define LON_ENUM(name) name
For other compilers, it can be defined as:
#define LON_ENUM(name) signed char
Example: Table 7 shows an example enumeration using the FTXL
LON_ENUM_* macros, and the equivalent ANSI C enumeration.
Table 7. Enumerations in FTXL
FTXL Enumeration
Equivalent ANSI C Enumeration
LON_ENUM_BEGIN(Color) {
red, green, blue
} LON_ENUM_END(Color);
typedef struct {
…
LON_ENUM(Color) color;
} Example;
enum {
red, green, blue
} Color;
typedef struct {
…
Color color;
} Example;
Floating Point Variables
Floating point variables receive special processing, because the Neuron C
compiler does not have built-in support for floating point types. Instead, it offers
an implementation for floating point arithmetic using a set of floating-point
support functions operating on a float_type type. The LonTalk Interface
Developer utility represents this type as a float_type structure, just like any
other structured type.