cppfront icon indicating copy to clipboard operation
cppfront copied to clipboard

[SUGGESTION] bitfields support

Open KaruroChori opened this issue 7 months ago • 2 comments

Quick question: is there any plan to support bitfields?
I know that they don't get much love as a feature in the broader community, but there are applications where they are the only sane option.
Alternatives which have been considered are:

  • To just write normal C++ structs/classes alongside Cpp2.
  • To write custom getters/setters handling the layout.

If nothing I guess the reflection/codegen feature of Cpp2 could even improve upon bitfields as it was done for enums.

KaruroChori avatar May 23 '25 09:05 KaruroChori

There's currently no bitfield implementation, closest thing would be @enum_flag, but thats for toggling individual bits and masking them together, you could try implementing a variant of what I described here: https://github.com/hsutter/cppfront/discussions/1390#discussioncomment-13012938 . I believe cppfront's reflection library has everything needed to do that, except accepting number only as identifiers.

DyXel avatar May 23 '25 09:05 DyXel

Thanks for the reference, I totally missed discussions were enabled in this repo while searching.

KaruroChori avatar May 23 '25 10:05 KaruroChori