Writing acceptable neuron c code, Anonymous top-level types – Echelon FTXL User Manual

Page 55

Advertising
background image

FTXL User’s Guide

43

Writing Acceptable Neuron C Code

When processing the model file, the LonTalk Interface Developer utility

distinguishes between three categories of Neuron C statements:

• Acceptable
• Ignored – ignored statements produce a warning
• Unacceptable – unacceptable statements produce an error

Appendix B,

Model File Compiler Directives

, on page 119, lists the acceptable

and ignored compiler directives for model files. All other compiler directives are

not accepted by the LonTalk Interface Developer utility and cause an error if

included in a model file. A statement can be unacceptable because it controls
features that are meaningless in an FTXL device, or because it refers to

attributes that are determined by the FTXL protocol stack or by other means.
The LonTalk Interface Developer utility ignores all executable code and I/O
object declarations. These constructs cause the LonTalk Interface Developer

utility to issue a warning message. The LonTalk Interface Developer utility
predefines the _FTXL and _MODEL_FILE macros, so that you can use #ifdef or

#ifndef compiler directives to control conditional compilation of source code that

is used for standard Neuron C compilation and as an FTXL model file.

All constructs not specifically mentioned as unacceptable or ignored are

acceptable.

Anonymous Top-Level Types

Anonymous top-level types are not acceptable. The following Neuron C construct
is not acceptable:

network output struct {int a; int b;} nvoZorro;

This statement is not acceptable because the type of the nvoZorro network

variable does not have a name. The LonTalk Interface Developer utility issues
an error when it detects such a construct.
Using a named type solves the problem, for example:

typedef struct {

int

a;

int

b;

} Zorro;

network output Zorro nvoZorro;

The use of anonymous sub-types is permitted. For example, the LonTalk
Interface Developer utility allows the following type definition:

typedef struct {

int a;
int b;

struct

{

long

x;

long

y;

long

z;

} c;

} Zorro;
network output Zorro nvoZorro;

Advertising