Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitfield generations for bools generate invalid comparison expressions (and errors) #508

Open
kkukshtel opened this issue Dec 7, 2023 · 2 comments

Comments

@kkukshtel
Copy link
Contributor

Screen Shot 2023-12-07 at 7 14 25 AM

For the get - "Cannot cast expression of type int to bool"
For the set - "Cannot apply operator & to operands of type bool and int.

Here's the relevant struct parts this is generated from:

struct ImGuiDockNode
{
     ...
    bool IsVisible :1;
    bool IsFocused :1;
    bool IsBgDrawnThisFrame :1;
    bool HasCloseButton :1;
    bool HasWindowMenuButton :1;
    bool HasCentralNodeChild :1;
    bool WantCloseAll :1;
    bool WantLockSizeOnce :1;
    bool WantMouseMove :1;
    bool WantHiddenTabBarUpdate :1;
    bool WantHiddenTabBarToggle :1;
};
@kkukshtel
Copy link
Contributor Author

kkukshtel commented Dec 7, 2023

Would a valid library fix here just be doing bool "conversion" by checking > 0 in the get and ternary switching for value in set?

@tannergooding
Copy link
Member

Will take a look in a bit. bool is generally tricky to handle due to it working completely differently between C/C++ and C#. Bitfields are apparently a scenario where I'm missing some of the manual conversions and comparisons that would otherwise be required.

In general it requires cond ? 1 : 0 to convert to a bool cond to an integer value and value != 0 to convert an int value to a boolean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants