You copied the Doc URL to your clipboard.

Arm Compiler armclang Reference Guide : __unaligned


The __unaligned keyword is a type qualifier that tells the compiler to treat the pointer or variable as an unaligned pointer or variable.

Members of packed structures might be unaligned. Use the __unaligned keyword on pointers that you use for accessing packed structures or members of packed structures.


typedef struct __attribute__((packed)) S{
    char c;
    int x;

int f1_load(__unaligned struct S *s)
    return s->x;

The compiler generates an error if you assign an unaligned pointer to a regular pointer without type casting.


struct __attribute__((packed)) S { char c; int x; };
void foo(__unaligned struct S *s2)
    int *p = &s2->x;             // compiler error because &s2->x is an unaligned pointer but p is a regular pointer.
    __unaligned int *q = &s2->x; // No error because q and &s2->x are both unaligned pointers.