From owner-freebsd-hackers Tue Jul 10 8:40:35 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from naboo.ethz.ch (naboo.ethz.ch [129.132.17.66]) by hub.freebsd.org (Postfix) with ESMTP id 831A037B401 for ; Tue, 10 Jul 2001 08:40:28 -0700 (PDT) (envelope-from carlo@vis.ethz.ch) Received: by naboo.ethz.ch (Postfix, from userid 224) id 6D8E6275B7; Tue, 10 Jul 2001 17:40:27 +0200 (CEST) Subject: Inconsistency with wchar_t / wint_t in current To: freebsd-hackers@FreeBSD.org Date: Tue, 10 Jul 2001 17:40:27 +0200 (CEST) X-Mailer: ELM [version 2.5 PL1] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20010710154027.6D8E6275B7@naboo.ethz.ch> From: carlo@vis.ethz.ch (Carlo Dapor) Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 , 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 #include 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 . 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