EasyManua.ls Logo

Intel i960 - Declaring Attributes of Functions

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...
Language Implementation
7-47
7
Array constructors whose elements are not simple constants are not very
useful because the constructor is not an lvalue. There are only two valid
ways to use it: to subscript it, or initialize an array variable with it. The
former is probably slower than a
switch statement, while the latter does
the same thing an ordinary C initializer would do.
output = ((int[]) { 2, x, 28 }) [input];
Declaring Attributes of Functions
You can declare certain things about functions called in your program that
help the compiler optimize function calls.
A few functions, such as
abort and exit, cannot return. These functions
should be declared
volatile. For example:
extern volatile void abort ();
tells the compiler that it can assume that abort does not return. This
makes slightly better code, but more importantly it helps avoid spurious
warnings of uninitialized variables.
Many functions do not examine any values except their arguments, and
have no effects except the return value. Such a function can be subject to
common subexpression elimination and loop optimization just as an
arithmetic operator would be. These functions should be declared
const.
For example:
extern const void square ();
says that the hypothetical function square is safe to call fewer times than
the program says. A function should not be declared
const unless:
no I/O is performed.
no non-local variables are read or modified either directly or via
pointers passed into the function.

Table of Contents

Related product manuals