[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AW: [avr-gcc-list] Union as parameter

From: Joerg Wunsch
Subject: Re: AW: [avr-gcc-list] Union as parameter
Date: Wed, 24 Aug 2005 14:40:54 +0200 (MET DST)

"Haase Bjoern (PT-BEU/EMT) *" <address@hidden> wrote:

> If the structure fits *exactly* into 2 byte, 4 byte or 8 byte, gcc
> internally is smart enough to allocate an object of type "int" HI,
> "long int" SI or "long long int" DI for the structure. Otherwise it
> allocates an object of mode BLK which forces the object to memory,
> i.e. forces it to the stack frame.

Ah, so it actually helps to declare the ``missing'' 13 bits in the

typedef union
        uint32_t dword;
        uint16_t word[2];
        uint8_t byte[4];
                uint16_t offset:7;
                uint16_t page:10;
                uint16_t bank:2;
                uint16_t :13;
        } bits;

That way, the bitfield fills up 32 bits, similar to all other tags of
the union.

J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]