[cairo] Cairo 1.6.4 build failing on AIX 52

Behdad Esfahbod behdad at behdad.org
Wed Jun 18 17:51:29 PDT 2008


On Wed, 2008-06-18 at 07:45 -0700, Carl Worth wrote:
> On Wed, 18 Jun 2008 05:19:59 -0400, Behdad Esfahbod wrote:
> > On Wed, 2008-06-18 at 14:12 +0530, Ashish Yadav wrote:
> > >
> > > What change I need to get this fixed?
> 
> Hi Ashish,
> 
> > I'd say, get a real ANSI C compiler.
> 
> Behdad, can you elaborate a bit on this? Specifically, can you point
> out what ANSI feature our code is relying on that Ashish's compiler
> doesn't appear to support?

It's hard to answer that question.  Compared to what other flavore of C.
Anyway, I wasn't thinking of any specific features.  Just noting that
our code compiles ok with decent ANSI C compilers.


> Ashish, you could start using gcc, for example, and we know that it
> will compile cairo's code correctly. But we really don't intend to
> limit cairo's portability to only systems using gcc.
> 
> Taking the first error:
> 
> > > While trying to compile Cairo 1.6.4 I get following errors:
> > >
> > > "cairo-xlib-surface.c", line 135.12: 1506-068 (S) Operation between types
> > > "struct {...}*" and "int" is not allowed.
> 
> It's not obvious what the compiler is complaining about. The code of
> interest looks like this:
> 
> 	static XRenderPictFormat *
> 	_CAIRO_FORMAT_TO_XRENDER_FORMAT(Display *dpy, cairo_format_t format)
> 	{
> 	    int pict_format;
> 	    ...
> 	    return XRenderFindStandardFormat (dpy, pict_format);
> 	}
> 
> Where XRenderFindStandardFormat should be declared, (for example, in
> /usr/include/X11/extensions/Xrender.h or so), with the following
> prototype:
> 
> 	XRenderPictFormat *
> 	XRenderFindStandardFormat (Display              *dpy,
> 	                           int                  format);
> 
> My first guess was that the compiler isn't seeing the prototype for
> XRenderFindStandardFormat, assuming it has a return-type of int,
> (supporting that old K&R style with non prototype), and then
> complaining.
> 
> Oh, but here's perhaps a more likely scenario. Is this on a system
> without a system-installed Xrender library? If so, then the definition
> of XRenderFindStandardFormat will instead be the macro inside
> cairo-xlib-xrender-private.h. And that appears to have some magic
> going on in it.
> 
> If that's the case, then you should be able to workaround the problem
> by simply installing the Xrender library.
> 
> And Behdad, can you help justify the magic going on in
> cairo-xlib-xrender-private.h? I just tweaked my cairo-features.h to
> disable CAIRO_HAS_XLIB_XRENDER_SURFACE and when compiling
> cairo-xlib-surface.c I got lots of warnings from gcc. Here's a
> sampling of them:
> 
> cairo-xlib-xrender-private.h:66: warning: function declaration isn't a prototype
> cairo-xlib-xrender-private.h: In function 'CONSUME2':
> cairo-xlib-xrender-private.h:66: warning: old-style function definition
> ...
> cairo-xlib-surface.c: In function '_CAIRO_FORMAT_TO_XRENDER_FORMAT':
> cairo-xlib-surface.c:135: warning: left-hand operand of comma expression has no effect
> cairo-xlib-surface.c:135: warning: pointer of type 'void *' used in
> arithmetic
> ...
> 
> The bunch of "statement with no effect" and "value computed is not
> used" are likely not much of a problem, (though I really would prefer
> to be offering people compilation without such a long string of
> warnings).
> 
> But "pointer of type 'void *' used in arithmetic" looks really bad to
> me. Isn't that something that a compiler could make an error? (I'm not
> looking up what any specifications might have to say on the matter
> now---but it seems like a nasty thing for us to be doing.)

All of the warning were safe.  The void* arithmetic was "NULL+0" which I
assume is safe with all compilers that matter.

Anyway, I rewrote the magic using variadic functions and the new version
is *MUCH* simpler.  And compiles with no warnings on gcc.  Now I'm not
sure if it's a service to compiling cleanly without xrender...  This
version is much more robust, and self documented.


Note: current master crashes when Xrender is not available.  Writing
another mail about that.


> -Carl

-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759



More information about the cairo mailing list