Re: Why keysym constants in gdk/gdkkeysyms.h are defined as macros, not as an enum?


2012/6/26 Mark Vender <markv743 yahoo co uk>:
> On 06/26/2012 05:31 PM, Bastien Nocera wrote:
>> If we used enums, we would restrict the keysyms to the declared values.
> Well, C doesn't actually have such restriction.

Yes and no, if you assign an integer to a variable of an enum type,
and if this integer is not one of the value defined for this enum
type, then this is undefined behaviour in the C standard.

> It's impossible for an application to break when enum values are added. They
> end up as integers within the code anyway and unless their values change,
> API/ABI stays the same.

Again, the C standard has some gotcha there, a compiler is allowed to
use a char-sized integer or an int-sized integer to store an enum, so
sizeof of an enum type can change if you add more values to it, which
could be an ABI break. And this is not purely theoretical, I think
llvm does this.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]