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

Wander Lairson Costa wander.lairson at gmail.com
Fri Oct 4 10:28:43 PDT 2013

2013/10/4 Thiago Macieira <thiago.macieira at intel.com>:
> On sexta-feira, 4 de outubro de 2013 09:09:32, Wander Lairson Costa wrote:
>> The issued raised when I took code from window.c in the weston clients:
>>         mask = xkb_state_serialize_mods(input->xkb.state,
>>                                         XKB_STATE_DEPRESSED |
>>                                         XKB_STATE_LATCHED);
>> g++ gave me a build error because I was passing an integer to enum
>> parameter. C++ is a bit more nit-picky than C regarding implicit
>> conversions. Therefore I had to use a cast.
> Like you said, it's window.c. Why are you copy & pasting C code into a C++
> file?

Well, weston clients are the only code reference I had in hand.
Sometimes I go to qtwayland also, but it did not run away from the

>> > With the ABI that GCC uses, it's always at least 4 bytes.
>> Personally, I don't like enum's in the ABI at all, because according
>> to C/C++ standards, the compiler is free to choose whatever type it
>> likes, and indeed I had problems with that in the past. C++11 fixed
>> that [1]. But nevermind.
> We're not relying on the ABI. I said "The enum must be backed by an integer
> with at least as many bits as the enum possesses.". If you cast back from an
> int that contains one of the enum values or an OR combination of enum values,
> it *will* fit.

I think I caused more confusion than explained here. My original point
was not if the value fits or not, but that once you do whatever math
with the enum, the result is not an enum type anymore (yes, sounds

Best Regards,
Wander Lairson Costa

More information about the wayland-devel mailing list