Hints (j.3.8) – Echelon Neuron C User Manual

Page 255

Advertising
background image

Neuron C Programmer’s Guide

243

Hints (J.3.8)

Q: What is the extent to which objects are actually placed in registers by use of

the

register

storage class specifier? (Sec. 6.7.1)

A:

The Neuron Chip uses a stack-based architecture. Because this architecture

has no general-purpose registers, the compiler ignores the register storage class.

The compiler also produces a warning diagnostic whenever the register class is
used.

Structures, Unions, Enumerations, and Bit-Fields
(J.3.9)

Q: Is a “plain”

int

bit-field treated as a

signed int

bit-field or as an

unsigned int

bit-field? (Sec. 6.7.2, Sec. 6.7.2.1)

A:

A “plain” int bit-field is treated as a signed int bit-field. Use of unsigned bit-

fields is recommended, unless a sign is needed, since unsigned bit-fields are more

efficient in runtime and code space.

Q: What is the order of allocation of bit-fields within a unit? (Sec. 6.7.2.1)

A:

Bit-fields are allocated from high-order bit (most-significant bit) to low-order

bit (least-significant bit) within a byte.

Q: Can a bit-field straddle a storage-unit boundary? (Sec. 6.7.2.1)

A:

No. A bit-field cannot straddle a byte boundary. Therefore, the largest bit-

field is 8 bits.

Q: What is the integer type chosen to represent the values of an enumeration

type? (Sec. 6.7.2.2)

A:

The integer type int is used to represent the values of an enumeration type.

Thus, the valid range of enumerator values is -128 ... 127.

Structures, Unions, Enumerations, and Bit-
Fields (F.3.9 of ANSI C Standard)

Q: What are the consequences of accessing a member of a union object with a

member of a different type? (Sec. 3.3.2.3)

A:

Union members of different types overlay each other at the same offsets

within a union. Thus, the consequences of accessing a pointer as a long or as an
unsigned long, or vice versa, are the same as casting the member. Likewise, the

consequences of accessing an int, or char, or short, as another typed member from
the same list is the same as casting the member. Accessing a long data type or

pointer data type as a short results in the value of the most significant byte.

Accessing a short data type as a long results in reading or changing an unused
byte (the least significant byte of the long), and the most significant byte of the

long mapping to the short.

Q: What is the padding and alignment of members of structures? (Sec. 3.5.2.1)

A:

Because the architecture of the Neuron Chip is byte aligned, no padding is

needed or performed between members of structures in Neuron C.

Advertising