You copied the Doc URL to your clipboard.

__attribute__((transparent_union)) type attribute

The transparent_union type attribute enables you to specify a transparent_union type, that is, a union data type qualified with __attribute__((transparent_union))__.

When a function is defined with a parameter having transparent union type, a call to the function with an argument of any type in the union results in the initialization of a union object whose member has the type of the passed argument and whose value is set to the value of the passed argument.

When a union data type is qualified with __attribute__((transparent_union)), the transparent union applies to all function parameters with that type.


This type attribute is a GNU compiler extension that the ARM compiler supports.


Individual function parameters might also be qualified with the corresponding __attribute__((transparent_union)) variable attribute.


typedef union { int i; float f; } U __attribute__((transparent_union));
void foo(U u)
    static int s;
    s += u.i;    /* Use the 'int' field */
void caller(void)
    foo(1);        /* u.i is set to 1 */
    foo(1.0f);     /* u.f is set to 1.0f */


Supported in GNU mode only.