[xkbcommon] Use an integer type for modifiers bit mask.

David Herrmann dh.herrmann at gmail.com
Fri Oct 4 06:22:59 PDT 2013


Hi

On Fri, Oct 4, 2013 at 2:34 PM, Daniel Stone <daniel at fooishbar.org> wrote:
> On 4 October 2013 13:09, Wander Lairson Costa <wander.lairson at gmail.com> wrote:
>> That's what the patch is about: avoid casts. Whenever you use a cast,
>> you are giving up the help the compiler may give to you regarding
>> invalid type conversions. So, I always use the rule of thumb of
>> avoiding casts whenever I can. IMO, this is not a harmful patch and
>> will make the C++ programmers a little bit easier.
>
> I can see where it's going, but on the other hand xkb_mod_mask_t is
> _so_ not the right type.  That's a bitmask of actual modifiers (i.e.
> the return value), not a bitmask of components.  So it avoids the
> cast, but also makes the API look extremely misleading, as we've
> documented exactly what xkb_mod_mask_t is.
>
> I really like the type safety aspect, so to be honest I'm just
> inclined to make C++ wear the cast for now.

We had a similar discussion when I pointed out that "enum" may change
the underlying type without notice when adding new enum-values. But I
agree with Daniel, the GCC type-safety for enums in C is a very handy
feature. So I'm also no big fan of the patch, sorry.

Thanks
David


More information about the wayland-devel mailing list