Datasheet
ARM Compiler Reference
ARM DUI 0067D Copyright © 1999-2001 ARM Limited. All rights reserved. 3-15
volatile
The standard ANSI qualifier
volatile
informs the compiler that the
qualified type contains data that can be changed from outside the
program. The compiler does not attempt to optimize accesses to
volatile
types. For example, volatile structures can be mapped onto
memory-mapped peripheral registers:
/* define a memory-mapped port register */
volatile unsigned *port = (unsigned int *) 0x40000000;
/* to access the port */
*port = value /* write to port */
value = *port /* read from port */
In ARM C and C++, a
volatile
object is accessed if any word or byte (or
halfword on ARM architectures with halfword support) of the object is
read or written. For
volatile
objects, reads and writes occur as directly
implied by the source code, in the order implied by the source code. The
effect of accessing a
volatile short
is undefined for ARM architectures
that do not support halfwords. Accessing volatile
packed
data is
undefined.
__weak
This storage class specifies an
extern
object declaration that, if not
present, does not cause the linker to fault an unresolved reference.
If the reference remains unresolved, its value is assumed to be
NULL
.
Unresolved references, however, are not
NULL
if the reference is from code
to a position-independent section or to a missing
__weak
function
(Example 3-4).
Example 3-4 Non-NULL unresolved references
__weak const int c; // assume 'c' is not present in final link
const int* f1() { return &c; } // '&c' will be non-NULL if
// compiled and linked /ropi
__weak int i; // assume 'i' is not present in final link
int* f2() { return &i; } // '&i' will be non-NULL if
// compiled and linked /rwpi
__weak void f(void); // assume 'f' is not present in final link
typedef void (*FP)(void);
FP g() { return f; } // 'g' will return non-NULL if
// compiled and linked /ropi
See also Function storage class modifiers on page 3-8.