Mail Archives: djgpp/1998/08/21/14:00:47
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 -