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

  1. Newsgroups: comp.std.c
  2. Path: sparky!uunet!usc!sdd.hp.com!elroy.jpl.nasa.gov!decwrl!deccrl!news.crl.dec.com!rdg.dec.com!uvo.dec.com!e2big.mko.dec.com!jrdzzz.jrd.dec.com!jit533.jit.dec.com!diamond
  3. From: diamond@jit533.jit.dec.com (Norman Diamond)
  4. Subject: Re: Mixing prototype and non-prototype issues
  5. Message-ID: <BzsKou.64C@jrd.dec.com>
  6. Sender: usenet@jrd.dec.com (USENET News System)
  7. Nntp-Posting-Host: jit533.jit.dec.com
  8. Reply-To: diamond@jit.dec.com (Norman Diamond)
  9. Organization: Digital Equipment Corporation Japan , Tokyo
  10. References: <1992Dec24.234622.29882@ll.mit.edu>
  11. Date: Fri, 25 Dec 1992 01:41:18 GMT
  12. Lines: 35
  13.  
  14. In article <1992Dec24.234622.29882@ll.mit.edu> tadams@ll.mit.edu ( Tony Adams) writes:
  15. >an example of a function call which is not governed by a prototype, calling
  16. >a (non-visible) function defined in prototype syntax.
  17. >Would someone please report the section numbers of the standard that
  18. >describe this programs combination of prototype and non-prototype usage.
  19. >            float   f=1.0;
  20. >            func(f); /* no declaration in prototype form is visible */
  21. >    /* definition of func() is not visible  from main() */
  22. >    func(float f) { printf("%f\n",f); }
  23. >    c.c:11: warning: type mismatch with previous implicit declaration
  24. >    c.c:6: warning: previous implicit declaration of `func'
  25.  
  26. ANSI Classic section 3.3.2.2, page 41 lines 28 to 32:  "If the expression
  27. that precedes the parenthesized argument list in a function call consists
  28. solely of an identifier, and if no declaration is visible for this identifier,
  29. the identifier is implicitly declared exactly as if, in the innermost block
  30. containing the function call, the declaration
  31.     extern int identifier();
  32. appeared."  Therefore your expression func(f) implies a declaration
  33.     extern int func();
  34.  
  35. Your actual definition occurs later and has a parameter type list.
  36.  
  37. ANSI Classic section 3.5.4.3, page 69 lines 14 to 18:  "If one type has a
  38. parameter type list and the other type is specified by a function declarator
  39. that is not part of a function definition and that contains an empty
  40. identifier list, the parameter list shall not have an ellipsis terminator
  41. and the type of each parameter shall be compatible with the type that
  42. results from the application of the default argument promotions."
  43. This is in a Semantics section, so a diagnostic is not required, though it
  44. is allowed, and any other undefined behavior is also allowed.
  45. --
  46. Norman Diamond       diamond@jit081.enet.dec.com
  47. If this were the company's opinion, I wouldn't be allowed to post it.
  48. "It's been a lovely recession."
  49.