[Xcb] Typed constants

Ian Osgood iano at quirkster.com
Fri Apr 28 15:21:13 PDT 2006


It also occurs to me that we could use another method for defining  
constants.  Many of the protocol struct-wrapped parameters can take  
"special" values. For example, most places an XCBTIMESTAMP is  
required, people will want to use CurrentTime.  Currently this  
requires an enum containing CurrentTime and a local definition;

   XCBTIMESTAMP now = { XCBCurrentTime };

to be type-correct. It would be nicer if we could export this kind of  
constant from the library directly. This would be a proto construct  
like:

   <const name="CurrentTime" type="TIMESTAMP"><value>0</value></const>

expanding in header mode to:

   extern const XCBTIMESTAMP XCBCurrentTime;

and in source mode to:

   const XCBTIMESTAMP XCBCurrentTime = { 0 };

Would this be hard to do? Does this have a downside I'm missing?

Ian


More information about the Xcb mailing list