| |||
| Home > Compiler Features > Compiler type attribute, __attribute__((bitband)) | |||
__attribute__((bitband)) is a type attribute
that is used to bit-band type definitions of structures.
In Example 28, the
unplaced bit-banded objects must be relocated into the bit-band
region. This can be achieved by either using an appropriate scatter-loading
description file or by using the --rw_base linker
command-line option.
Example 28. Unplaced object
/* foo.c */
typedef struct {
int i : 1;
int j : 2;
int k : 3;
} BB __attribute__((bitband));
BB value; // Unplaced object
void update_value(void)
{
value.i = 1;
value.j = 0;
}
/* end of foo.c */
Alternatively, __attribute__((at())) can
be used to place bit-banded objects at a particular address in the
bit-band region. See Example 29.
Example 29. Placed object
/* foo.c */
typedef struct {
int i : 1;
int j : 2;
int k : 3;
} BB __attribute((bitband));
BB value __attribute__((at(0x20000040))); // Placed object
void update_value(void)
{
value.i = 1;
value.j = 0;
}
/* end of foo.c */
Compiler Reference:
Linker Reference:
Technical Reference Manual for your processor.