home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / linux / 9100 < prev    next >
Encoding:
Text File  |  1992-08-25  |  1.5 KB  |  55 lines

  1. Path: sparky!uunet!zephyr.ens.tek.com!uw-beaver!news.u.washington.edu!serval!poly2!hlu
  2. From: hlu@poly2.eecs.wsu.edu (H.J. Lu)
  3. Newsgroups: comp.os.linux
  4. Subject: Re: gcc compiler bug involving <linux/ctype.h>?
  5. Message-ID: <1992Aug26.040036.10148@serval.net.wsu.edu>
  6. Date: 26 Aug 92 04:00:36 GMT
  7. References: <1992Aug26.020845.15618@watson.ibm.com>
  8. Sender: hlu@poly2 (H.J. Lu)
  9. Organization: Washington State University
  10. Lines: 43
  11.  
  12. In article <1992Aug26.020845.15618@watson.ibm.com>, derek@watson.ibm.com (Derek Lieber) writes:
  13. |> The program below prints:
  14. |>      1
  15. |>      1
  16. |> but should print:
  17. |>      0
  18. |>      1
  19. |> 
  20. |> -------------------bug.c-------------------------
  21. |> #include <linux/ctype.h>
  22. |> main()
  23. |>    {
  24. |>    printf("%d\n",  toupper('x') == toupper('y'));
  25. |>    printf("%d\n",  toupper('x') == toupper('X'));
  26. |>    }
  27. |> -------------------------------------------------
  28. |> 
  29. |> The problem seems to be due to the toupper macro defined in <linux/ctype.h>.
  30. |> The macro looks fine to me, but changing it from...
  31. |> 
  32. |> #define toupper(c)          (_ctmp=c,islower(_ctmp)?_ctmp-('a'-'A'):_ctmp)
  33. |> 
  34. |> to...
  35. |> 
  36. |> inline  toupper(c) { return (_ctmp=c,islower(_ctmp)?_ctmp-('a'-'A'):_ctmp); }
  37. |> 
  38. |> ...makes the problem go away.
  39. |> 
  40. |> Is this a compiler bug? (I'm using gcc 2.2.2).
  41. |> 
  42. |
  43.  
  44. /usr/include/linux is for kernel only. No one should ever use them in
  45. any user code.
  46.  
  47. BTW, some header files in /usr/include and /usr/include/sys do include files
  48. in /usr/include/linux. But you should not do it yourself.
  49.  
  50. Please use
  51.  
  52. #include <ctype.h>
  53.  
  54. H.J.
  55.