cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/21/00:01:07

From: jpalluch AT aol DOT com (JPalluch)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Problems defining external symbols in C++ !?
Lines: 37
Message-ID: <1998082104000300.AAA26295@ladder03.news.aol.com>
NNTP-Posting-Host: ladder03.news.aol.com
Date: 21 Aug 1998 04:00:02 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

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


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019