[Xcb] [PATCH] c_client.py: Prefer bit shifts over values in enum
Ran Benita
ran234 at gmail.com
Tue Jul 29 14:14:58 PDT 2014
On Tue, Jul 29, 2014 at 04:59:12PM -0400, Peter Harris wrote:
> On 2014-07-29 16:26, Daniel Martin wrote:
> > Any idea or wish how I should change the patch, how the resulting value
> > should like?
>
> 0x80000000 simply isn't representable in an enum in standard C.
Can you explain how this patch makes things worse in this regard?
(You mentioned a gcc extension, which one?).
> Ideally, the resulting value should[1] look like
>
> #define XCB_XKB_CONTROL_CONTROLS_ENABLED (1u << 31u)
>
> outside of the rest of the enum, and s/enum xcb_xkb_control_t/uint32_t/g
> (if you find a user in our API). Except I'm not sure we can, because it
> might qualify as a change to the API, or at least to the potential set
> of warnings you might get when using it.
There's the option of actually using the negative value, i.e.
-2147483648 (if I got it right) (assuming 2's complement) - though I
won't advocate for that.
> Peter Harris
>
> [1] Or, for maximum portability and minimum readability,
> #define XCB_XKB_CONTROL_CONTROLS_ENABLED (UINT32_C(1) << UINT32_C(31))
>
> Ick.
More information about the Xcb
mailing list