[cairo] compiler warnings in cairo_wideint.h/c

Owen Taylor otaylor at redhat.com
Wed Oct 13 13:49:53 PDT 2004

On Wed, 2004-10-13 at 09:10 -0700, Keith Packard wrote:
> Around 8 o'clock on Oct 13, "Andreas Tobler" wrote:
> > /* Type qualifiers on a function return type are
> >    normally permitted by the standard but have no
> >    effect.
> > */
> Hmm.  The effect I was trying to induce was to teach the compiler that 
> given fixed arguments, these functions always return the same result 
> (i.e., they are "pure" functions).  I thought that's what the 'const' 
> qualifier on the return value did.

GCC apparently supports:

          typedef int intfn (int val);
          extern const intfn square;

As a synonym for 

 int square (int val) __attribute__ ((const));

But I don't think it's any more portable than the the __attribute__
version, and considerably harder to macroize into something portable.
(GLib has G_GNUC_CONST, G_GNUC_PURE that get #defined to nothing when
not available.)

See the gcc info pages for information on the 'const' and 'pure' 
attributes; I haven't seen any real evidence that they improve code
generation, but they certainly can't hurt.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20041013/a8dd8f0f/attachment.pgp

More information about the cairo mailing list