Re: Help on bit operation
Randi Botse <[email protected]>
| Newsgroups | org.kernel.vger.linux-c-programming |
|---|---|
| Message-ID | <[email protected]> |
everything is clear now!, thanks all for your guides and patience.
- Randi
On Sat, Aug 29, 2009 at 3:19 AM, Glynn Clements<[email protected]> wrote:
>
> Randi Botse wrote:
>
>> Ben, after assign all bitfield struct member, how to pack them to be a
>> 32bit integer value?
>
> The structure should be 32 bits wide. If you need the value as a
> uint32_t, either use a union:
>
> union bits_or_int {
> struct bitfield fields;
> uint32_t value;
> };
>
> or a cast, e.g.:
>
> struct bitfield foo;
> ...
> uint32_t value = *(uint32_t *)&foo;
>
> --
> Glynn Clements <[email protected]>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html