We've faced an issue, when we used wl_array_for_each in our C++ wayland client implementation.
The problem is that one can't use wl_array_for_each(pos, array) when
pos is passed as uint32_t*, for example, and array->data is assigned to it. In C++, one cannot just convert void* to other pointer type implicitly as in C.
Is it possible to modify the macro defined to have explicit type cast?
#define wl_array_for_each(pos, array) \
for (pos = (uint32_t*) (array)->data; \
or maybe intptr_t before (array)->data ??.
I'm not sure which one would be better, but it is to you to decide.
It cannot be cast to uint32_t as the type is not known in advance; for example, the modifiers_map request from the text_input protocol uses an array of uint8_t.
Is it possible to do the cast with typeof(*pos)? Every time I think I remember how type-casting works in C++ I'm wrong, so maybe it wouldn't work.
Well, (typeof(pos)) works well, IIRC, C++ doesn't have such a thing like typeof. decltype is used instead. Of course, one can use typeof with C++, but it's rather a compile extension rather than the feature of the language.
s/Well, (typeof(pos)) works well, IIRC,/Well, (typeof(pos)) works well, BUT IIRC,/
-- GitLab Migration Automatic Message --
This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.
You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/wayland/wayland/issues/34.