Texas Instruments TMS34010 Reference Manual page 46

C compiler
Hide thumbs Also See for TMS34010:
Table of Contents

Advertisement

TMS34010 C
Language - Declarations
K&R states that structure and union member names must be mutually
distinct. In TMS3401 0 C, members of different structures or un-
ions can have the same name. However, this requires that references
to the member be fully qualified through all levels of nesting.
o
TMS34010 C allows assignment to and from structures, passing struc-
tures as parameters, and returning structures from functions.
K&R contains a statement about the compiler determining the type of a
structure reference by the member name. Since TMS3401 0 C does not
require member names to be unique, this statement does not apply. All
structure references must be fully qualified as members of the structure
or union in which they were declared.
Added Type - Enumeration Declarations
Enumerations allow the use of named integer constants in TMS3401 0 C. The
syntax of an enumeration declaration is similar to that of a structure or union.
The keyword
enum
is substituted for
struct
or
union,
and a list of enumerators
is substituted for the list of members.
Enumeration declarations have a
tag,
as do structure and union declarations.
This tag may be used in future declarations, without repeating the entire dec-
laration.
The list of enumerators is simply a comma-separated list of identifiers. Each
identifier can be followed by an equal sign and an integer constant. If there
is no enumerator followed by an
=
sign and a value, then the first enumerator
is assigned the value 0, the next is 1, the next is 2, etc. An identifier with an
assigned value assumes that value; the next enumerator is assigned that value
+
1, the next is the preceding value
+
1, etc. The assigned value may be ne-
gative, but the increments are still by positive 1.
The size of an object of type
enum
is determined as follows: if any of the ob-
ject's enumerators have negative values, the object occupies 32 bits. Other-
wise, the object occupies the minimum number of bits required to represent
the largest enumerator value and is considered to be unsigned.
Unlike structure and union members, enumerators share their name space with
ordinary variables and, therefore, must not conflict with variables or other en-
umerators in the same scope.
Enumerators can appear wherever integer constants are required; thus, they
can be used in arithmetic expressions, case expressions, etc.· In addition, ex-
plicit integer expressions may be assigned to variables of type
enum.
The
compiler does no range checking to insure the value will fit in the enumeration
field. The compiler does, however, issue a warning message if an enumerator
of one type is assigned to a variable of another.
Here's an example of an enumerator declaration:
enum color
red,
blue,
green
10,
orange,
purple
-2,
cyan }
:X;
4-9

Advertisement

Table of Contents
loading

Table of Contents