Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #389511
| Path | csiph.com!weretis.net!feeder9.news.weretis.net!news.quux.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
| Newsgroups | comp.lang.c |
| Subject | Re: question about linker |
| Date | Sat, 07 Dec 2024 15:50:01 -0800 |
| Organization | None to speak of |
| Lines | 66 |
| Message-ID | <875xnvxdcm.fsf@nosuchdomain.example.com> (permalink) |
| References | <vi54e9$3ie0o$1@dont-email.me> <vila9j$3j4dg$1@dont-email.me> <vin4su$49a6$1@dont-email.me> <vin95m$5da6$1@dont-email.me> <vinh3h$7ppb$1@dont-email.me> <vinjf8$8jur$1@dont-email.me> <vip5rf$p44n$1@dont-email.me> <viprao$umjj$1@dont-email.me> <viqfk9$13esp$1@dont-email.me> <viqhmn$131h8$3@dont-email.me> <visbmp$1ks59$1@dont-email.me> <visgs7$1mgdb$1@dont-email.me> <viv5ve$2dqir$1@dont-email.me> <vivggi$2gkth$1@dont-email.me> <vj1r8n$35lal$1@dont-email.me> <vj1uge$36ugq$1@dont-email.me> <vj22ce$37g4b$1@dont-email.me> <vj263c$396ln$1@dont-email.me> <vj2d21$3aqf3$1@dont-email.me> <vj2e34$3b1j8$1@dont-email.me> <87msh7xf19.fsf@bsb.me.uk> |
| MIME-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Date | Sun, 08 Dec 2024 00:50:23 +0100 (CET) |
| Injection-Info | dont-email.me; posting-host="a2786d5d7eda6e71f287de5e917519d7"; logging-data="3570241"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1871PZovoMaroJ4YxiPbchS" |
| User-Agent | Gnus/5.13 (Gnus v5.13) |
| Cancel-Lock | sha1:08UAUWer4i+j1G2g6Xzwr5qXHy4= sha1:kV8LUeoGpRefnhlNDebgPn3k9Vo= |
| Xref | csiph.com comp.lang.c:389511 |
Show key headers only | View raw
Ben Bacarisse <ben@bsb.me.uk> writes:
[...]
> I've always wondered why prototypes in C did not simply use the existing
> syntax for declarations. After all, it was right there in K&R C, just
> outside the parentheses:
>
> f(m, n, s)
> int m, n;
> char *s;
> { ... }
>
> could have become
>
> f(int m, n; char *s)
> { ... }
>
> rather than
>
> f(int m, int n, char *s)
> { ... }
>
> Does anyone know if there even /was/ a reason?
The ANSI C Rationale doesn't provide any illumination on this point.
Function prototypes were borrowed from C++, as I recall, so it might
be mentioned in Stroustrup's "The Design and Evolution of C++".
(I have a paper copy, but it's inaccessible.)
For consistency with existing declaration syntax, there should
probably be a semicolon after each declaration, including the
last one:
void func(int arg;);
but an exception to omit the semicolon before the ")" would not have
been unreasonable. (Struct members follow declaration syntax more
closely, but unlike function declarations they're commonly written on
multiple lines and they're enclosed in {} rather than ().)
One weak argument for the existing syntax is that the use of commas
between parameter declarations mirrors the use of commas between
arguments in a call.
But functions with multiple parameters of the same type aren't so
common that allowing them to be grouped would be all that much of
an advantage. And the syntax wouldn't match exactly anyway, since
many kinds of declarations aren't allowed within in a prototype
and parameter declarations can't have initializers. (Though the
latter could be used for default values.)
And even in ordinary declarations, a common style guideline is to
use a single declaration for each declared entity, for example
int a;
int b;
rather than
int a, b;
or especially
int x;
int *y;
rather than
int x, *y;
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar
Re: question about linker David Brown <david.brown@hesbynett.no> - 2024-12-06 16:41 +0100
Re: question about linker Bart <bc@freeuk.com> - 2024-12-06 18:41 +0000
Re: question about linker Ike Naar <ike@sdf.org> - 2024-12-06 19:14 +0000
Re: question about linker Bart <bc@freeuk.com> - 2024-12-06 19:27 +0000
Re: question about linker scott@slp53.sl.home (Scott Lurndal) - 2024-12-06 22:30 +0000
Re: question about linker Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-12-06 15:17 -0800
Re: question about linker Bart <bc@freeuk.com> - 2024-12-07 00:30 +0000
Re: question about linker Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-12-06 18:01 -0800
Re: question about linker David Brown <david.brown@hesbynett.no> - 2024-12-07 16:57 +0100
Re: question about linker Bart <bc@freeuk.com> - 2024-12-07 16:52 +0000
Re: question about linker David Brown <david.brown@hesbynett.no> - 2024-12-07 18:58 +0100
Re: question about linker Bart <bc@freeuk.com> - 2024-12-07 19:02 +0000
Re: question about linker David Brown <david.brown@hesbynett.no> - 2024-12-07 22:00 +0100
Re: question about linker Bart <bc@freeuk.com> - 2024-12-07 21:18 +0000
Re: question about linker Ben Bacarisse <ben@bsb.me.uk> - 2024-12-07 23:13 +0000
Re: question about linker Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-12-07 15:50 -0800
Re: question about linker Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-12-11 08:52 -0800
Re: question about linker David Brown <david.brown@hesbynett.no> - 2024-12-08 11:52 +0100
Re: question about linker antispam@fricas.org (Waldek Hebisch) - 2024-12-08 22:52 +0000
Re: question about linker Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-12-09 18:35 +0100
Re: question about linker bart <bc@freeuk.com> - 2024-12-10 12:10 +0000
csiph-web