home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 16790 < prev    next >
Encoding:
Text File  |  1992-11-19  |  2.0 KB  |  75 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!wupost!uwm.edu!caen!sol.ctr.columbia.edu!ira.uka.de!math.fu-berlin.de!hamel!rene
  3. From: rene@hamel.uucp (Rene Mueller)
  4. Subject: Re: question about duplicate declarations
  5. Message-ID: <2R28E4L@math.fu-berlin.de>
  6. Sender: rene@hamel (Rene Mueller)
  7. Organization: Free University of Berlin, Germany
  8. References: <1992Oct17.104808.29033@mccc.edu> <1849@lysator.liu.se> <26961@dog.ee.lbl.gov> <1992Oct26.172233.2045@mccc.edu> <26987@dog.ee.lbl.gov> <720329596@sheol.UUCP>
  9. Date: Thu, 19 Nov 1992 16:11:53 GMT
  10. Lines: 63
  11.  
  12. In article <720329596@sheol.UUCP>, throopw@sheol.UUCP (Wayne Throop) writes:
  13. |> I didn't see anybody else mention it specifically, but it's relevant to
  14. |> some of the earlier postings; note that:
  15. |> 
  16. |>          float a(float);
  17. |>          void f(void) {
  18. |>                  float a();       /* gak! */
  19. |>                  ...
  20. |>          }
  21. |> or
  22. |>          short a(short);
  23. |>          void f(void) {
  24. |>                  short a();       /* gak! */
  25. |>                  ...
  26. |>          }
  27. |> 
  28. |> is *also* a malicious redeclaration, not a benign one.  Arguably, the
  29. |> compiler could deal with the inner by "enhancing" it to match the outer
  30. |> (though this is a Bad Idea in my opinion), but there would be a good
  31. |> deal more trouble with, eg:
  32. |> 
  33. |>          float a();
  34. |>          void f1(void) {
  35. |>                  a(1.0);
  36. |>          }
  37. |>          void f2(void) {
  38. |>                  float a(float);       /* gak! */
  39. |>                  a(1.0);
  40. |>          }
  41.  
  42. In a function there couldn't be a fuctiondefinition..
  43. So code like
  44. typ f1(paramlist)
  45. {
  46. typ f2(paramlist);
  47.     .
  48.     .
  49.     .
  50. }
  51. Shouldn't be in ANY programm...
  52. and things like
  53. typ f();
  54. means that f is a function with NO parameter returning a value from type typ
  55. (perhaps nothing if typ==void), so typ f(paramlist) is a redeclaration with WRONG
  56. type
  57. That means:
  58.  
  59. float a();
  60.  
  61. void f1(void)
  62. {
  63.     a(1.0);
  64. }
  65.  
  66. void f2(void)
  67. {
  68. float a();
  69.     a(1.0);
  70. }
  71.  
  72. won't produce an error (perhaps a warning: "parameter to a() ignored").
  73.  
  74.     Rene
  75.