Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #148882
| From | Steve Keller <keller@no.invalid> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: K&R function definition with typedef parameter names |
| Date | 2020-01-09 06:26 -0800 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <qv7d72$1o7v$1@gioia.aioe.org> (permalink) |
| References | <qurl9m$b69$1@gioia.aioe.org> <87blrimu2f.fsf@bsb.me.uk> |
Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
> Steve Keller <keller@no.invalid> writes:
>
> > typedef int t;
> > int fun(t)
> > int t;
> > {
> > return 0;
> > }
>
> At least one pre-ANSI C compiler (pcc) accepts this code.
OK, that's interesting and it is what I have assumed.
> ANSI C includes the wording:
>
> "An identifier declared as a typedef name shall not be redeclared as a
> parameter."
>
> in 3.7.1. The corresponding text in the reference manual at the end of
> K&R1 is missing, so I think this was a deliberate change designed to
> facilitate parsing of new-style function declarations and definitions.
Ok, I've found this also in ISO C 9899 in 6.9.1 and it covers only
old-style function definitions. Therefore, to convert such code to
the current standard you may write
typedef int t;
int fun(int t)
{
return 0;
}
and all compilers I have do accept this.
Steve
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
K&R function definition with typedef parameter names Steve Keller <keller@no.invalid> - 2020-01-04 19:31 -0800
Re: K&R function definition with typedef parameter names Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-05 04:00 +0000
Re: K&R function definition with typedef parameter names Steve Keller <keller@no.invalid> - 2020-01-09 06:26 -0800
Re: K&R function definition with typedef parameter names James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-04 23:15 -0500
Re: K&R function definition with typedef parameter names Steve Keller <keller@no.invalid> - 2020-01-09 06:27 -0800
Re: K&R function definition with typedef parameter names Bonita Montero <Bonita.Montero@gmail.com> - 2020-01-05 06:47 +0100
Re: K&R function definition with typedef parameter names Steve Keller <keller@no.invalid> - 2020-01-09 06:25 -0800
Re: K&R function definition with typedef parameter names Bonita Montero <Bonita.Montero@gmail.com> - 2020-01-09 16:22 +0100
Re: K&R function definition with typedef parameter names James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-09 08:20 -0800
Re: K&R function definition with typedef parameter names Thiago Adams <thiago.adams@gmail.com> - 2020-01-09 10:49 -0800
Re: K&R function definition with typedef parameter names David Brown <david.brown@hesbynett.no> - 2020-01-10 10:22 +0100
Re: K&R function definition with typedef parameter names Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-10 13:05 +0000
Re: K&R function definition with typedef parameter names David Brown <david.brown@hesbynett.no> - 2020-01-10 16:14 +0100
Re: K&R function definition with typedef parameter names Richard Damon <Richard@Damon-Family.org> - 2020-01-10 11:15 -0500
Re: K&R function definition with typedef parameter names James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-10 20:51 -0500
Re: K&R function definition with typedef parameter names Thiago Adams <thiago.adams@gmail.com> - 2020-01-10 06:24 -0800
Re: K&R function definition with typedef parameter names David Brown <david.brown@hesbynett.no> - 2020-01-10 16:26 +0100
Re: K&R function definition with typedef parameter names Nick Bowler <nbowler@draconx.ca> - 2020-01-13 22:12 +0000
Re: K&R function definition with typedef parameter names Autist <autist69@gmail.com> - 2020-01-10 16:42 +0100
Re: K&R function definition with typedef parameter names Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-01-11 09:56 -0800
csiph-web