I'm hoping someone has run into this sort of problem before, and can give me a hint to solve it.
With Microsoft Visual C++ 2005, I have this code in a program:
DWORD locator[FOURXFLAGCOUNT+1]={
0x58585858, 0x58585858, 0x58585858, 0x58585858, 0x58585858,
0x58585858, 0x58585858, 0x58585858, 0x58585858, 0x58585858,
0x58585858, 0x58585858, 0x58585858, 0x58585858, 0x58585858,
0x58585858, 0x58585858, 0x58585858, 0x58585858, 0x58585858,
0x58585858, 0x58585858, 0x58585858, 0x58585858, 0x58585858,
0x58585858, 0x58585858, 0x58585858, 0x58585858, 0x58585858,
0x58585858, 0x58585858, 0x58585858, 0x58585858, 0x58585858,
0x58585858, 0x58585858, 0x58585858, 0x00000000
};
The idea is to make the locator
discoverable (and fillable) from outside the program -- i.e. another program is filling it in, so that this program will have it built in when it starts up. This is for an anti-theft thing, so there's no conventional way to get the data, it has to be done something like this.
This worked just fine when I was compiling the program on its own, but when I added a static library to the program, the data vanished. The locator
symbol is still there; the data it's supposed to be initialized with (and which is supposed to be visible outside it) isn't.
The linker switch /OPT:NOREF solves the problem, but at an unacceptable price: the program grows by several hundred K (doesn't seem like much, but it is in this case). Using the #pragma comment(linker, "/include:?locator@@BLAHBLAH")
(don't remember what the "BLAHBLAH" part was) did nothing -- the locator
symbol is already visible, it's just not initialized. Moving the locator
definition into the library doesn't help either.
Ditching the static library is a last resort, I'd rather not do it if I can avoid it.
Any ideas?