[PATCH:libX11 1/2] Bug 32098: Making XInternAtoms take const char ** breaks callers
Alan Coopersmith
alan.coopersmith at oracle.com
Mon Dec 13 17:22:58 PST 2010
Callers who had successfully built without issues with the existing
libX11 headers were suddenly either given warnings or errors (-Werror)
with the new headers.
This compromise solution allows us to move to the correct declaration
without breaking such callers - if they simply include the headers as
is, nothing changes for them. If they want to take advantage of the
new const declaration to avoid getting warnings from passing arrays of
string literals, then they can #define XINTERNATOMS_WANT_CONST_NAMES
before they #include <X11/Xlib.h>. Callers using pkg-config will
eventually be able to require x11 > 1.4 to get this - those not using
pkg-config or not wanting a hard requirement can simply check after
the #include <X11/Xlib.h> for #ifdef XINTERNATOMS_HAVE_CONST_NAMES
to see if the header is new enough to have satisfied their request.
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
include/X11/Xlib.h | 5 +++++
src/IntAtom.c | 2 ++
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/include/X11/Xlib.h b/include/X11/Xlib.h
index b0d7d4d..c33019e 100644
--- a/include/X11/Xlib.h
+++ b/include/X11/Xlib.h
@@ -1548,7 +1548,12 @@ extern Atom XInternAtom(
);
extern Status XInternAtoms(
Display* /* dpy */,
+#ifdef XINTERNATOMS_WANT_CONST_NAMES
+# define XINTERNATOMS_HAVE_CONST_NAMES
_Xconst char** /* names */,
+#else
+ char** /* names */,
+#endif
int /* count */,
Bool /* onlyIfExists */,
Atom* /* atoms_return */
diff --git a/src/IntAtom.c b/src/IntAtom.c
index 80d78c0..751584a 100644
--- a/src/IntAtom.c
+++ b/src/IntAtom.c
@@ -26,6 +26,8 @@ from The Open Group.
*/
+#define XINTERNATOMS_WANT_CONST_NAMES /* must come before Xlib.h is included */
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
--
1.7.3.2
More information about the xorg-devel
mailing list