On Sun, 16 Dec 2012 15:32:48 -0500 Behdad Esfahbod <beh...@behdad.org> wrote:
> On 12-12-16 12:13 AM, Siarhei Siamashka wrote: > > -#define PIXMAN_null PIXMAN_FORMAT (0, 0, 0, 0, 0, 0) > > -#define PIXMAN_solid PIXMAN_FORMAT (0, 1, 0, 0, 0, 0) > > -#define PIXMAN_pixbuf PIXMAN_FORMAT (0, 2, 0, 0, 0, 0) > > -#define PIXMAN_rpixbuf PIXMAN_FORMAT (0, 3, 0, 0, 0, 0) > > -#define PIXMAN_unknown PIXMAN_FORMAT (0, 4, 0, 0, 0, 0) > > -#define PIXMAN_any PIXMAN_FORMAT (0, 5, 0, 0, 0, 0) > > +#define PIXMAN_null ((pixman_format_code_t) PIXMAN_FORMAT (0, 0, 0, 0, > > 0, 0)) > > +#define PIXMAN_solid ((pixman_format_code_t) PIXMAN_FORMAT (0, 1, 0, 0, > > 0, 0)) > > +#define PIXMAN_pixbuf ((pixman_format_code_t) PIXMAN_FORMAT (0, 2, 0, 0, > > 0, 0)) > > +#define PIXMAN_rpixbuf ((pixman_format_code_t) PIXMAN_FORMAT (0, 3, 0, 0, > > 0, 0)) > > +#define PIXMAN_unknown ((pixman_format_code_t) PIXMAN_FORMAT (0, 4, 0, 0, > > 0, 0)) > > +#define PIXMAN_any ((pixman_format_code_t) PIXMAN_FORMAT (0, 5, 0, 0, > > 0, 0)) > > Clearly the cast belongs to inside the PIXMAN_FORMAT macro... It does not work this way. The problem is that PIXMAN_FORMAT macro is used to initialize pixman_format_code_t enum itself (we get a variation of a chicken/egg issue and C++ compilers do not like it either): http://cgit.freedesktop.org/pixman/tree/pixman/pixman.h?id=pixman-0.28.2#n664 Arguably PIXMAN_null, PIXMAN_solid and the other constants actually belong to this pixman_format_code_t enum in "pixman.h", but they are not supposed to be exposed in the public header. That's why they are somewhat artificially introduced in "pixman-private.h". Also another thing that I don't quite like in this patch is the code from "pixman-x86.c": -typedef enum -{ +typedef int cpu_features_t; + +enum { X86_MMX = (1 << 0), X86_MMX_EXTENSIONS = (1 << 1), X86_SSE = (1 << 2) | X86_MMX_EXTENSIONS, X86_SSE2 = (1 << 3), X86_CMOV = (1 << 4) -} cpu_features_t; +}; Using enum for bit flags is a bit cumbersome in C++: http://stackoverflow.com/questions/199606/how-should-c-bitflag-enumerations-be-translated-into-c -- Best regards, Siarhei Siamashka _______________________________________________ Pixman mailing list Pixman@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/pixman