home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- 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
- From: rene@hamel.uucp (Rene Mueller)
- Subject: Re: question about duplicate declarations
- Message-ID: <2R28E4L@math.fu-berlin.de>
- Sender: rene@hamel (Rene Mueller)
- Organization: Free University of Berlin, Germany
- 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>
- Date: Thu, 19 Nov 1992 16:11:53 GMT
- Lines: 63
-
- In article <720329596@sheol.UUCP>, throopw@sheol.UUCP (Wayne Throop) writes:
- |> I didn't see anybody else mention it specifically, but it's relevant to
- |> some of the earlier postings; note that:
- |>
- |> float a(float);
- |> void f(void) {
- |> float a(); /* gak! */
- |> ...
- |> }
- |> or
- |> short a(short);
- |> void f(void) {
- |> short a(); /* gak! */
- |> ...
- |> }
- |>
- |> is *also* a malicious redeclaration, not a benign one. Arguably, the
- |> compiler could deal with the inner by "enhancing" it to match the outer
- |> (though this is a Bad Idea in my opinion), but there would be a good
- |> deal more trouble with, eg:
- |>
- |> float a();
- |> void f1(void) {
- |> a(1.0);
- |> }
- |> void f2(void) {
- |> float a(float); /* gak! */
- |> a(1.0);
- |> }
-
- In a function there couldn't be a fuctiondefinition..
- So code like
- typ f1(paramlist)
- {
- typ f2(paramlist);
- .
- .
- .
- }
- Shouldn't be in ANY programm...
- and things like
- typ f();
- means that f is a function with NO parameter returning a value from type typ
- (perhaps nothing if typ==void), so typ f(paramlist) is a redeclaration with WRONG
- type
- That means:
-
- float a();
-
- void f1(void)
- {
- a(1.0);
- }
-
- void f2(void)
- {
- float a();
- a(1.0);
- }
-
- won't produce an error (perhaps a warning: "parameter to a() ignored").
-
- Rene
-