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

Thiago Macieira thiago.macieira at intel.com
Fri Oct 4 08:56:13 PDT 2013


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?

> > 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.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20131004/289332ae/attachment.pgp>


More information about the wayland-devel mailing list