Global and Extern Pointers, Arrays

John Gordon gordon at osiris.cso.uiuc.edu
Fri May 24 06:10:29 AEST 1991


aj3u at agate.cs.virginia.edu (Asim Jalis) writes:

>I just figured out the following bug in my program.  I had a global
>array, with some initialized value that I was also declared an extern
>pointer in the other files that accessing it.  This turns out to be a
>no-no.  The bug went away when I changed the extern definition to an
>array also.  

>Here is the code:

>file.1
>	struct x px[1] = { ... };

>file.2
>	extern *px	/* boinks */
>	extern px[]	/* works */

>Any ideas as to why this is?

	Arrays and pointers are mostly analogous most of the time.  However,
this is one of the things about them that are NOT the same.

John



More information about the Comp.lang.c mailing list