Bug 45881 - bit offset of bitfields
Summary: bit offset of bitfields
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: unknown
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-04 13:59 UTC by Jan Waclawek
Modified: 2021-09-13 21:50 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-08-28 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Waclawek 2010-10-04 13:59:10 UTC
A (builtin) function, returning bit offset for bitfields within structs, could be useful to pass bit "addresses" as function parameters.

In analogy to offsetof()/sizeof(), a similar function returning number of bits of a bitfield could be created, too, although it would be less useful than the offset.
Comment 1 Andrew Pinski 2021-08-28 03:57:01 UTC
I thought I saw a paper about adding this and even bit sized types.
Comment 2 Andrew Pinski 2021-09-13 20:47:11 UTC
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2763.pdf

It seems like they did not add this ...

But they do have _Bitwidthof now ...
Comment 3 Jan Waclawek 2021-09-13 21:50:29 UTC
Thanks for the comments and the link.

Small embedded is generally frowned upon. The proposal is characteristically heavyweight and unwieldy.

Maybe in C5x.