wchar_t mismatch between Xlib.h and stddef.h

From: Iain McClatchie (iain@10xinc.com)
Date: Tue Apr 25 2000 - 10:04:13 EST


GCC-2.95.2
Xfree86 3.3.5
RedHat 6.1 on an SMP PII

While attempting to compile Magic-6.5.1, I get the following error:
gcc `cat ../misc/CFLAGS` `cat ../misc/DFLAGS` -I. -I../include
-I/usr/openwin/include -c grX11su1.c
In file included from grX11su1.c:47:
/usr/X11R6/include/X11/Xlib.h:83: conflicting types for `wchar_t'
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/include/stddef.h:255: previous
declaration of `wchar_t'

The comments around the definition in stddef.h seem significant:

#ifndef X_WCHAR
#include <stddef.h>
#else
#ifdef __EMX__
#include <stdlib.h>
#else
#ifdef DGUX
/* DG/ux needs this always! */
#include <stddef.h>
#else
/* replace this with #include or typedef appropriate for your system */
typedef unsigned long wchar_t;
#endif
#endif
#endif

I'm pulling in that last unsigned long definition.

It's clear to me what _should_ be happening: stddef.h should define
wchar_t, and Xlib.h should notice that it's already defined and
leave it alone.

CFLAGS, above, defines the macros SYSV and linux, to say what
platform is being compiled for. This causes lots of the right
things to happen, but SYSV also causes Xosdefs.h to define
X_NOT_STDC_ENV (the logic is that defined(i386) && defined( SYSV )
&& !defined( ISC ) && !defined( SCO ) leads to X_NOT_STDC_ENV).

Xlib.h defines X_WCHAR in response to X_NOT_STDC_ENV, which then
causes it to typedef wchar_t in the above code.

So that makes me think that SYSV should be turned off for Linux
compilations. But that doesn't sound right... is it? The
alternative is to hack Xlib.h -- which isn't something I really
want to be doing.

I also get lots of other problems attempting to get a clean build.
In particular, it appears <string.h> gets included after many of
the magic-specific includes, which leads to macro conflicts. There
are also some issues with string.h not being included when it should.
I'd like to help fix these problems if I could get some guidance on
the right kind of fix.

-Iain McClatchie 650-364-0520 voice
http://www.10xinc.com 650-364-0530 FAX
iain@10xinc.com 650-906-8832 cell

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Apr 30 2000 - 21:00:09 EST