Bug 45881

Summary: bit offset of bitfields
Product: gcc Reporter: Jan Waclawek <konfera>
Component: cAssignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: enhancement    
Priority: P3    
Version: unknown   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2021-08-28 00:00:00

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.