Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!boingo.med.jhu.edu!haven.umd.edu!umbc3.umbc.edu!gmuvax2!xwang From: xwang@gmuvax2.gmu.edu (Xiang-Min Wang) Newsgroups: comp.lang.c Subject: Re: Global and Extern Pointers, Arrays Message-ID: <1991May30.210730.18222@gmuvax2.gmu.edu> Date: 30 May 91 21:07:30 GMT References: Distribution: comp Organization: George Mason University, Fairfax, Va. Lines: 31 In article aj3u@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? > >Asim Jalis. Hi, Asim. in your file 'file.2', you should declare px as extern struct x px[1] telling the compiter that px[1] is of type 'struct x' but do not need bother allocating memory for it. as to why your second solution works, well, there are a lot of luck out there in c programming. so good luck. xwang