[Spice-devel] [Xspice PATCH 08/11] configure: include assert.h and values.h (fix compiler warning y1)

Uri Lublin uril at redhat.com
Mon Jan 26 02:35:40 PST 2015


The compiler warns about a function being shadowed by a local
variable named y1. Apparently y1 is a name of a Bessel function
of the math library.
For example:
  uxa-glyphs.c: In function ‘uxa_glyph_extents’:
  uxa-glyphs.c:310: warning: declaration of ‘y1’ shadows a global declaration
  /usr/include/bits/mathcalls.h:242: warning: shadowed declaration is here

The function y1 is included in math.h, which is included
in xorg/misc.h, but only if one of the following constants is not defined:
  MAXSHORT, MINSHORT MAXINT MININT

Including values.h defines MAX/MIN SHORT/INT, thus math.h is not included
and the compiler is happy.

Also include assert.h before values.h, as it seems to be required.

Note: the following appears on the top of values.h, but I think it's better
to ignore this recommendation such that math.h is not included. Also note
that values.h includes limits.h:
  /* This interface is obsolete.  New programs should use
     <limits.h> and/or <float.h> instead of <values.h>.  */
---

Is there a better way to solve this ?
I thought of renaming the variable but x1,y1,x2,y2 seem good short names.

----
 configure.ac |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index 27b1cc7..80445a8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -46,6 +46,8 @@ AC_DISABLE_STATIC
 AC_PROG_INSTALL
 AC_PROG_LIBTOOL
 
+AH_TOP([#include <assert.h>])
+AH_TOP([#include <values.h>])
 AH_TOP([#include "xorg-server.h"])
 
 # Define a configure option for an alternate module directory
-- 
1.7.1



More information about the Spice-devel mailing list