home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / sgi / 18653 < prev    next >
Encoding:
Internet Message Format  |  1993-01-10  |  1.9 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!howland.reston.ans.net!spool.mu.edu!olivea!sgigate!sgi!quasar.mti.sgi.com!davea
  2. From: davea@quasar.mti.sgi.com (David B.Anderson)
  3. Newsgroups: comp.sys.sgi
  4. Subject: Re: C problems (was Re: compiling metamail)
  5. Message-ID: <unccg9s@sgi.sgi.com>
  6. Date: 10 Jan 93 22:01:04 GMT
  7. Sender: davea@quasar.mti.sgi.com
  8. Organization: Silicon Graphics, Inc.  Mountain View, CA
  9. Lines: 40
  10.  
  11. In article <1993Jan10.004920.13004@biome.bio.ns.ca> silvert@biome.bio.dfo.ca (Bill Silvert) writes:
  12. >Thanks for the one posting that suggested a solution.  However, I found
  13. >the answer, and since it is a common one I felt a further posting on the
  14. >subject is called for.
  15. >
  16. >In this case and others, a file contains this sort of code:
  17. >
  18. >    ...
  19. >    x = DoSomething(...);
  20. >    ...
  21. >
  22. >static int DoSomething(...) { ... }
  23. >
  24. >On an SGI system this causes DoSomething to be an unsatisfied external
  25. >unless the function occurs before the invocation, or at least is
  26. >declared before it is invoked.  Apparently on other systems this is
  27. >acceptable.
  28.  
  29. The 3.10 ANSI  (I think it is 4.1-IDO) says:
  30. accom: Warning 338: davea2.c, line 8: Linkage conflict. Identifier "x" extern in local scope yet static at file scope. Put declaration at file scope before existing references/declarations.
  31.        {
  32.        ^
  33.  
  34. So at least you do get a warning before link time with that version.
  35.  
  36.  
  37. >I don't know whether the SGI touchiness agrees with the standard, but
  38.  
  39. I believe that this falls into "undefined behavior".
  40. I don't have a copy of the Standard at home to quote chapter and verse.
  41. But I agree this compiler behavior is unfriendly.
  42.  
  43. >this is a real pain.  Does anyone have a general solution?
  44.  
  45. No (sorry). The C compiler for the next major release gives a warning
  46. for this but connects the call and the definition so "DoSomething" is
  47. found.
  48.  
  49. Regards,
  50. [ David B. Anderson             (415)390-4263             davea@sgi.com ]
  51.