From: jpalluch AT aol DOT com (JPalluch) Newsgroups: comp.os.msdos.djgpp Subject: Re: Problems defining external symbols in C++ !? Lines: 37 Message-ID: <1998082117503000.NAA18323@ladder01.news.aol.com> NNTP-Posting-Host: ladder01.news.aol.com Date: 21 Aug 1998 17:50:29 GMT References: <35dcd766 DOT 101916239 AT news DOT pathcom DOT com> Organization: AOL Bertelsmann Online GmbH & Co. KG http://www.germany.aol.com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Im Artikel <35dcd766 DOT 101916239 AT news DOT pathcom DOT com>, oliver AT jesus DOT hv (Oliver Richman) schreibt: >I am converting a large C program to C++ using DJGPP, and all is going >well, but for some reason when I do this: > >from moo.cc: >const struct moostruct moovariable[] = { ... } > >from moo2.cc: >extern const struct moostruct moovariable[]; > >I get an "undefined reference to moovariable" in moo2.cc. > > A const is automatically static, so your compiler needs to see the extern declaration of moovariable in moo.cc too. Do it just this way: moo.h: extern const struct moostruct moovariable[]; moo.cc: #include "moo.h" const struct moostruct moovariable[] = { ... } moo2.cc: #include "moo.h" // without this line: extern const struct moostruct moovariable[]; This should help. Jens