home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zephyr.ens.tek.com!uw-beaver!news.u.washington.edu!serval!poly2!hlu
- From: hlu@poly2.eecs.wsu.edu (H.J. Lu)
- Newsgroups: comp.os.linux
- Subject: Re: gcc compiler bug involving <linux/ctype.h>?
- Message-ID: <1992Aug26.040036.10148@serval.net.wsu.edu>
- Date: 26 Aug 92 04:00:36 GMT
- References: <1992Aug26.020845.15618@watson.ibm.com>
- Sender: hlu@poly2 (H.J. Lu)
- Organization: Washington State University
- Lines: 43
-
- In article <1992Aug26.020845.15618@watson.ibm.com>, derek@watson.ibm.com (Derek Lieber) writes:
- |> The program below prints:
- |> 1
- |> 1
- |> but should print:
- |> 0
- |> 1
- |>
- |> -------------------bug.c-------------------------
- |> #include <linux/ctype.h>
- |> main()
- |> {
- |> printf("%d\n", toupper('x') == toupper('y'));
- |> printf("%d\n", toupper('x') == toupper('X'));
- |> }
- |> -------------------------------------------------
- |>
- |> The problem seems to be due to the toupper macro defined in <linux/ctype.h>.
- |> The macro looks fine to me, but changing it from...
- |>
- |> #define toupper(c) (_ctmp=c,islower(_ctmp)?_ctmp-('a'-'A'):_ctmp)
- |>
- |> to...
- |>
- |> inline toupper(c) { return (_ctmp=c,islower(_ctmp)?_ctmp-('a'-'A'):_ctmp); }
- |>
- |> ...makes the problem go away.
- |>
- |> Is this a compiler bug? (I'm using gcc 2.2.2).
- |>
- |
-
- /usr/include/linux is for kernel only. No one should ever use them in
- any user code.
-
- BTW, some header files in /usr/include and /usr/include/sys do include files
- in /usr/include/linux. But you should not do it yourself.
-
- Please use
-
- #include <ctype.h>
-
- H.J.
-