Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: extern array as a pointer Date: Tue, 12 Jul 2016 09:30:56 -0700 Organization: None to speak of Lines: 24 Message-ID: References: <27db6ff2-216f-41c6-a9e0-c06d206f5262@googlegroups.com> <20160712135839.349cd1a4@archvm> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="10518"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/R6EmNLHzFbuDSVw1Piox+" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:bid2gbFiOyVeCg3wfSjbO1A//cQ= sha1:t+oaCWrqO1RLXPs2y40NVa1gVog= Xref: csiph.com comp.lang.c:90283 Frank Tetzel writes: [...] > But why? Why is "extern int *array" containing the first element which > is 0? Why doesn't the compiler or rather the linker warn about this? Is > the type information lost for the linker? Yes, that's exactly the problem: the linker is required to pay attention to type information. Careful use of header files, so you don't have multiple unchecked declarations of the same thing, can avoid problems like this. > In the past i used *array and array[] interchangeable. I might have to > reconsider that. Please do. And read section 6 of the comp.lang.c FAQ: http://www.c-faq.com/ -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"