EasyManua.ls Logo

Intel i960 - Non-Constant Initializers

Intel i960
347 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
i960 Processor Compiler User's Guide
7-46
7
Non-constant Initializers
The elements of an aggregate initializer for an automatic variable are not
required to be constant expressions. Here is an example of an initializer
with run-time varying elements:
foo (float f, float g)
{
float beat_freqs[2] = { f-g, f+g };
...
}
Constructor Expressions
Constructor expressions are supported. A constructor looks like a cast
containing an initializer. Its value is an object of the type specified in the
cast, containing the elements specified in the initializer. The type must be
a structure, union or array type.
Assume that
struct foo and structure are declared as shown:
struct foo {int a; char b[2];} structure;
Here is an example of constructing a struct foo with a constructor:
structure = ((struct foo) {x + y, ’a’, 0});
This is equivalent to writing the following:
{
struct foo temp = {x + y, ’a’, 0};
structure = temp;
}
You can also construct an array. If all the elements of the constructor are
(made up of) simple constant expressions, suitable for use in initializers,
then the constructor is a lvalue and can be coerced to a pointer to its first
element, as shown here:
char **foo = (char *[]) { "x", "y", "z" };

Table of Contents

Related product manuals