From: dontmailme AT iname DOT com (Steamer) Newsgroups: comp.os.msdos.djgpp Subject: Re: Pointers and Arrays (Newbie) Date: Wed, 28 Jun 2000 12:05:31 GMT Organization: always disorganized Lines: 23 Message-ID: <3959e9e8.18221152@news.freeserve.net> References: <39535e20 AT news DOT telinco DOT net> <39587ba3$1 AT news DOT telinco DOT net> <39588b61 DOT 13985194 AT news DOT freeserve DOT net> <3959ba51 AT news DOT telinco DOT net> NNTP-Posting-Host: modem-27.clarkes-clownfish.dialup.pol.co.uk X-Trace: news6.svr.pol.co.uk 962193932 23864 62.136.213.27 (28 Jun 2000 12:05:32 GMT) NNTP-Posting-Date: 28 Jun 2000 12:05:32 GMT X-Complaints-To: abuse AT theplanet DOT net X-Newsreader: Forte Free Agent 1.11/32.235 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Adrian Smith wrote: > That seems to cure it ! Could somebody explain to me why and what the > 'extern' statement is used for in this context. You should check a good reference book (or even the standard itself) for full details about 'extern'. But in this context, the extern declaration extern const char * message; tells the compiler that the object 'message' has type 'const char*' and has external linkage. Once the compiler has seen this declaration it knows enough about 'message' to correctly compile any code that uses it. But the extern declaration doesn't actually create an object, so there needs to be an actual definition somewhere. You can put the definition in any source file. (But you can only put it in one source file, otherwise you have multiple objects with external linkage all sharing the same name, which is not possible. This is what you were doing wrong, because you were #including a definition into two different source files.) S.