
98 Using the LonTalk Interface Developer Utility
Enumerations
The LonTalk Interface Developer utility does not produce enumerations. The
LonTalk Stack 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.
The LonTalk Stack 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
The following table shows an example enumeration using the LonTalk Stack
LON_ENUM_* macros, and the equivalent ANSI C enumeration.
LonTalk Stack 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.
This floating-point format can represent numbers with the following
characteristics:
•
1038
10*1± approximate maximum value
Comentarios a estos manuales