This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/9694] New: Including wchar.h then wctype.h can break stddef.h


This simple C program fails to compile when using glibc 2.8 (I'm using gcc 4.3.0
on Fedora 9).

#include <wchar.h>
#include <wctype.h>
#include <stddef.h>
ptrdiff_t i;

The error is:

foo.c:4: error: expected ?=?, ?,?, ?;?, ?asm? or ?__attribute__? before ?i?

The error is because the typedef for ptrdiff_t was not defined by <stddef.h>. 
That happens because wctype.h does this:

/* Get wint_t from <wchar.h>.  */
# define __need_wint_t
# include <wchar.h>

Unfortunately, if the program has already #included <wchar.h>, then _WCHAR_H is
defined and <wchar.h> does nothing, including not doing a #undef of
__need_wint_t.  The presence of the __need_wint_t then causes <stddef.h> to only
define wint_t, and not define the types it should normally define when it is
included directly.

It seems to me that either wctype.h should not #include wchar.h, or wchar.h
should reliably #undef __need_wint_t.

-- 
           Summary: Including wchar.h then wctype.h can break stddef.h
           Product: glibc
           Version: 2.8
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: ian at airs dot com
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=9694

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]