Re: Help on bit operation

Glynn Clements <[email protected]>
Newsgroups org.kernel.vger.linux-c-programming
Message-ID <[email protected]>
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]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.