Replies: 3 comments 2 replies
-
|
It would avoid bugs where the enum grows, but the bitfield is not updated. I think we can add it as a keyword. It should only accept a type as input (or module.type). T.b is not needed for the bitfield case. |
Beta Was this translation helpful? Give feedback.
-
|
A struct is always the full size, leftover bits from bitfields dont get merged to the next struct. So in case of T.b, it would be 32 bits. numbits is indeed a name programmers might want to use. Other names i could think of:
I also like bitsizeof, that might even be an accurate description of what it does ;) |
Beta Was this translation helpful? Give feedback.
-
|
yes the bitfields in the AST were the use case i had in mind. bitsizeof(T.b) is not something useful, so the argument I would like is only a Type or module.Type. Requesting bitsizeof() of (anonymous) Struct members has no real use-case. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
To help cram enumerations in bitfields, we could have a
bitsizeof()builtin operator that computes the number of bits for an expression or type at compile time:Some corner cases are up for discussion:
Beta Was this translation helpful? Give feedback.
All reactions