home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / c / 18847 < prev    next >
Encoding:
Text File  |  1992-12-23  |  1.5 KB  |  49 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!gatech!destroyer!ais.org!draper
  3. From: draper@ais.org (Patrick Draper)
  4. Subject: Is this ANSI?
  5. Message-ID: <BzqnK1.8t6@ais.org>
  6. Organization: UMCC
  7. Date: Thu, 24 Dec 1992 00:47:58 GMT
  8. Lines: 39
  9.  
  10. I was playing with the Turbo C++ 1.01 compiler, and I found that it choked
  11. on this code:
  12.  
  13. void foo (struct bar *x);
  14.  
  15. struct bar {
  16.    int aaa;
  17.    int bbb;
  18. };
  19.  
  20. void foo (struct bar *x)
  21. {
  22.  
  23.    ....
  24.  
  25. }
  26.  
  27. It complained about the redeclaration of function foo. If I put the
  28. structure definition before the prototype, Turbo C++ 1.01 is happy.
  29.  
  30. This code works just fine with the borland C++ 2.0 and Borland C++ 3.1
  31. compilers, and that leads me to suspect that the Turbo C++ 1.01 is not
  32. strictly ANSI in this regard.
  33.  
  34. My question is: what does ANSI say about this. Stylistically, I can see that
  35. it is preferable to define the structure before I use it, however, it is
  36. defined in the global realm, thus should be visible.
  37.  
  38. Is this an artifact of a one pass vs. two pass compiler? (I don't know if
  39. Turbo C++ 1.01 is one pass or not)
  40.  
  41. Thanks,
  42.  
  43. ------------------////////////////////\\\\\\\\\\\\\\\\\\\\------------------
  44. | Patrick Draper-ZBT       Disclaimer:  I can't control my fingers,        |
  45. | draper@umcc.ais.org                   I can't control my toes! - Ramones |
  46. | University of Michigan Computer Club                                     |
  47. NO CARRIER                     We are a nation of laws, not people         |
  48. ------------------\\\\\\\\\\\\\\\\\\\\////////////////////------------------
  49.