Date: Tue, 10 Jul 2001 17:40:27 +0200 (CEST) From: carlo@vis.ethz.ch (Carlo Dapor) To: freebsd-hackers@FreeBSD.org Subject: Inconsistency with wchar_t / wint_t in current Message-ID: <20010710154027.6D8E6275B7@naboo.ethz.ch>
index | next in thread | raw e-mail
Dear fellow hackers
I stumbled over an inconsistency with the data types wchar_t and wint_t.
My machine is a FreeBSD-5.0 current as of July 8th, 2001.
This following simple source code breaks unless You modify <stddef.h>,
see below.
/* stddef.h is included by curses.h, but here I want to make sure the
* modified version of stddef.h is picked up !
*/
#include <stddef.h>
#include <curses.h>
int
main (char *argv[], int argc) {
printf ("size of wchar_t is %d\n", sizeof (wchar_t));
printf ("size of wint_t is %d\n", sizeof (wint_t));
exit (0);
return 0;
}
The error is:
gcc -I. -O -Os -pipe -s -o mess mess.c
mess.c: In function `main':
mess.c:8: `wint_t' undeclared (first use in this function)
mess.c:8: (Each undeclared identifier is reported only once
mess.c:8: for each function it appears in.)
*** Error code 1
Stop in /usr/tmp/wchar-mess.
There are two different definitions of the both data types wchar_t and wint_t.
Please refer to the output of the commands at the end of this mail.
We have (n)curses.h, defining them both unsigned long;
We have runetype,stddef,stdlib,wchar,wctype, defining them as
_BSD_WCHAR_T_ / _BSD_WINT_T_ resp.
_BSD_W{CHAR,INT}_T_ are defined in <machine/ansi.h>.
Also, (n)curses is FSF originated, as oulined in the disclaimer.
Now, I expected some symmetry here, note that wint_t is not defined in either
{runetype,stddef,stdlib,wchar}.h.
Also, wchar_t is not defined in wctype.h.
The definitions in curses.h are dangerous, they should use _BSD_WCHAR_T_ /
_BSD_WINT_T_, and both data types must be defined in the header files mentioned
above.
Is somebody working on reconciling the header files ?
Eventually I fixed the build by inserting the following lines in a local
stddef.h:
*** /usr/include/stddef.h Fri May 25 02:29:30 2001
--- stddef.h Mon Jul 9 21:02:25 2001
***************
*** 61 ****
--- 62,66 ----
+ #ifdef _BSD_WINT_T_
+ typedef _BSD_WINT_T_ wint_t;
+ #undef _BSD_WINT_T_
+ #endif
+
Ciao, derweil,
--
Carlo
PS: Here are the revealing commands !
"fgrep wchar_t /usr/include/*.h /usr/include/sys/*.h | fgrep typedef" shows
/usr/include/curses.h:typedef unsigned long wchar_t;
/usr/include/ncurses.h:typedef unsigned long wchar_t;
/usr/include/runetype.h:typedef _BSD_WCHAR_T_ wchar_t;
/usr/include/stddef.h:typedef _BSD_WCHAR_T_ wchar_t;
/usr/include/stdlib.h:typedef _BSD_WCHAR_T_ wchar_t;
/usr/include/wchar.h:typedef _BSD_WCHAR_T_ wchar_t;
Whereas "fgrep wint_t /usr/include/*.h /usr/include/sys/*.h | fgrep typedef"
results in
/usr/include/curses.h:typedef long int wint_t;
/usr/include/ncurses.h:typedef long int wint_t;
/usr/include/wchar.h:typedef _BSD_WINT_T_ wint_t;
/usr/include/wctype.h:typedef _BSD_WINT_T_ wint_t;
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010710154027.6D8E6275B7>
