am trying to access the SilenceList silencePlayer in playing.cxx *in* dumpResources() which is part of bzflag.cxx so I can dump the list into the resources database (more or less).
I have done this numberous ways, all of which result in an undefined symbol link error (VC++)
My current iteration has nothing in bzflag.cxx,
moved BZF_DEFINE_ALIST(SilenceList, BzfString);
into playing.h (which is included into bzflag.cxx, right?),
Then I added the following to playing,h
class SilenceList; //?
extern SilenceList silencePlayers; //?
Then I have static SilenceList silencePlayers; in playing.cxx....
I think this would made SilenceList global in all the files, which is not needed. And I would think all I would need would be to define the list class in playing.h and extern SilenceList silencePlayers in bzflag.cxx, and then I should be able to use SilenceList in bzflag.cxx and have it be the one from playing.cxx...
But.. this -------> undefined symbol error in linking which is driving me wonkers. Am I missing something about how the files are put together? Does being a macro do something here?
Tried using extern SilenceList * silencePlayers --> did NOT work
Ohhh arise extern wizards! Want silencePlayers in bzflag.cxx
-
- Private First Class
- Posts: 57
- Joined: Thu Dec 12, 2002 2:28 am
- Location: MN USA
-
- Private First Class
- Posts: 57
- Joined: Thu Dec 12, 2002 2:28 am
- Location: MN USA
- purple_cow
- Private First Class
- Posts: 63
- Joined: Sun Dec 15, 2002 9:24 pm
-
- Private First Class
- Posts: 57
- Joined: Thu Dec 12, 2002 2:28 am
- Location: MN USA
Re: Ohhh arise extern wizards! Want silencePlayers in bzflag
you know the purpose of `static' at file scope is to hide a symbol from the linker. no amount of `extern' is going to change that. did you try removing `static' from the line in playing.cxx?michaelh20 wrote:Then I added the following to playing,h
class SilenceList; //?
extern SilenceList silencePlayers; //?
Then I have static SilenceList silencePlayers; in playing.cxx....
p.s. i'm guessing that your getSlienceList() function was visible because you didn't declare it static. i.e. you did
Code: Select all
SilenceList& getSilenceList();
Code: Select all
static SilenceList& getSilenceList();