-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
undefined behaviour with wl_container_of #7
Comments
Thanks for bringing this to my attention, gcc didn't complain :P you wanna wrap a MR or should I do it? |
im actually out on an island in a second home? cottage? with the kids and i think im gonna end up throwing the laptop into the sea before i figure out this std::format madness xD, so if you can please <3 |
if you wanna sneak peak into how QT did their wayland scanner the source is here https://code.qt.io/cgit/qt/qtwayland.git/tree/src/qtwaylandscanner/qtwaylandscanner.cpp |
my bad, enjoy your time with the kids. I don't have any. Or a wife. Or a single woman who'd not hate me. Heh. |
heh it changes fast, when you least expect it to. but i managed to somewhat figure out something without throwing the laptop into the sea #8 :D |
yeah, left a small review |
to safely use that C macro the class has to be "no virtual functions, no inheritance, and uniform access control (e.g., all public)"
currently hyprland breaks this. easiest solution to work around this is store both the listener and the type *data; inside
but im hitting std::format struggles complaining all from not being a consteval expression when trying to make a PR, std::format struggles hehe.
examples in wayfire https://github.com/WayfireWM/wayfire/blob/master/src/wl-listener-wrapper.tpp#L8
decleration https://github.com/WayfireWM/wayfire/blob/master/src/api/wayfire/util.hpp#L19
or example in wrapland https://github.com/winft/wrapland/blob/master/server/buffer.cpp#L344
decleration https://github.com/winft/wrapland/blob/master/server/buffer_p.h#L32
the reason behind this is the macro wl_container_of, which relies on offsetof to compute the offset of a member within a structure. and classes can work with this if adhereing to those rules mentioned at top.
this can be seen when compiling hyprland with extra warnings or with clang.
The text was updated successfully, but these errors were encountered: