Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Nobody <nobody@nowhere.invalid> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Question about extern declaration |
| Date | 2016-09-19 13:38 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <pan.2016.09.19.12.38.38.849000@nowhere.invalid> (permalink) |
| References | <nrn6m7$mpr$1@news.xmission.com> |
On Sun, 18 Sep 2016 23:06:47 +0000, Kenny McCormack wrote: > So, what, really, is the difference between the two forms (specifically, > in an extern statement)? One is a pointer to a pointer, the other is an array of pointers. Arrays and pointers are equivalent in some contexts, but not all. If you use an array as a "value", the value is a pointer to the first element. This covers enough cases that it's not that hard to mislead yourself that there's no difference between them. It also doesn't help that C allows you to declare a function parameter as an array even though what's actually being passed is a pointer. Presumably this feature exists for "documentation", i.e. to distinguish a pointer to a single value from a pointer to the first of many values. The equivalence doesn't apply to any other variable declaration (extern, "static" global, global with external linkage, "static" local, automatic local), because in those cases you can declare variables which are actually arrays, whereas function parameters can't be arrays.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Question about extern declaration gazelle@shell.xmission.com (Kenny McCormack) - 2016-09-18 23:06 +0000
Re: Question about extern declaration supercat@casperkitty.com - 2016-09-18 16:33 -0700
Re: Question about extern declaration BartC <bc@freeuk.com> - 2016-09-19 01:02 +0100
Re: Question about extern declaration Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-19 01:23 +0100
Re: Question about extern declaration BartC <bc@freeuk.com> - 2016-09-19 10:40 +0100
Re: Question about extern declaration m.labanowicz@gmail.com - 2016-09-19 03:27 -0700
Re: Question about extern declaration Nobody <nobody@nowhere.invalid> - 2016-09-19 13:38 +0100
Re: Question about extern declaration Keith Thompson <kst-u@mib.org> - 2016-09-19 11:46 -0700
csiph-web