home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.std.c
- 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
- From: diamond@jit533.jit.dec.com (Norman Diamond)
- Subject: Re: Mixing prototype and non-prototype issues
- Message-ID: <BzsKou.64C@jrd.dec.com>
- Sender: usenet@jrd.dec.com (USENET News System)
- Nntp-Posting-Host: jit533.jit.dec.com
- Reply-To: diamond@jit.dec.com (Norman Diamond)
- Organization: Digital Equipment Corporation Japan , Tokyo
- References: <1992Dec24.234622.29882@ll.mit.edu>
- Date: Fri, 25 Dec 1992 01:41:18 GMT
- Lines: 35
-
- In article <1992Dec24.234622.29882@ll.mit.edu> tadams@ll.mit.edu ( Tony Adams) writes:
- >an example of a function call which is not governed by a prototype, calling
- >a (non-visible) function defined in prototype syntax.
- >Would someone please report the section numbers of the standard that
- >describe this programs combination of prototype and non-prototype usage.
- > float f=1.0;
- > func(f); /* no declaration in prototype form is visible */
- > /* definition of func() is not visible from main() */
- > func(float f) { printf("%f\n",f); }
- > c.c:11: warning: type mismatch with previous implicit declaration
- > c.c:6: warning: previous implicit declaration of `func'
-
- ANSI Classic section 3.3.2.2, page 41 lines 28 to 32: "If the expression
- that precedes the parenthesized argument list in a function call consists
- solely of an identifier, and if no declaration is visible for this identifier,
- the identifier is implicitly declared exactly as if, in the innermost block
- containing the function call, the declaration
- extern int identifier();
- appeared." Therefore your expression func(f) implies a declaration
- extern int func();
-
- Your actual definition occurs later and has a parameter type list.
-
- ANSI Classic section 3.5.4.3, page 69 lines 14 to 18: "If one type has a
- parameter type list and the other type is specified by a function declarator
- that is not part of a function definition and that contains an empty
- identifier list, the parameter list shall not have an ellipsis terminator
- and the type of each parameter shall be compatible with the type that
- results from the application of the default argument promotions."
- This is in a Semantics section, so a diagnostic is not required, though it
- is allowed, and any other undefined behavior is also allowed.
- --
- Norman Diamond diamond@jit081.enet.dec.com
- If this were the company's opinion, I wouldn't be allowed to post it.
- "It's been a lovely recession."
-