Atmel CAVR-4 Manual De Usuario
CAVR-4
Part 2. Compiler reference
IAR language extensions
277
Casting pointers to integers in static initializers
In an initializer, a pointer constant value may be cast to an integral type if the integral
type is large enough to contain it.
type is large enough to contain it.
In the following example, it is assumed that pointers to
_ _near
and
_ _huge
are 16 and
32 bits, respectively. The first initialization is correct, because it is possible to cast the
16-bit address to a 16-bit
16-bit address to a 16-bit
unsigned
short
variable. However, it is illegal to use the
32-bit address of
b
as an initializer for a 16-bit value.
_ _near int a;
_ _huge int b;
unsigned short ap = (unsigned short)&a; /* Correct */
unsigned short bp = (unsigned short)&b; /* Error */
Hexadecimal floating-point constants
Floating-point constants can be given in hexadecimal style. The syntax is
0xMANTp{+|-}EXP
, where
MANT
is the mantissa in hexadecimal digits, including an
optional
.
(decimal point), and
EXP
is the exponent with decimal digits, representing an
exponent of 2.
Examples
0x1p0
is
1
0xA.8p2
is
10.5*2^2
Using the bool data type in C
To use the
bool
type in C source code, you must include the file
stdbool.h
. (The
bool
data type is supported by default in C++.)
Taking the address of a register variable
In ISO/ANSI C, it is illegal to take the address of a variable specified as a register
variable.
variable.
The AVR IAR C/C++ Compiler allows this, but a warning is issued.
Duplicated size and sign specifiers
Should the size or sign specifiers be duplicated (for example,
short
short
or
unsigned
unsigned
), an error is issued.
"long float" means "double"
long
float
is accepted as a synonym for
double
.