I need a global variable, which will be used from several .exe.
My code:
Log_clnt.cpp
With other files, it will generated a logclnt.lib.Code:string text_messages [NUM_MAX_MESSAGES];
SVLog.cpp
I link SVLog.cpp with logclnt.lib and I generate an executable logserv.exeCode:#include "util/log_clnt.h" extern string text_messages [NUM_MAX_MESSAGES]; int servMain (int argc,char *argv[]) { string value; for (int i=0; i < NUM_MAX_MESSAGES; i++) { #ifdef WIN32 stringstream strsStream; #else strstream strsStream; #endif strsStream << i; if (!c.getValueForVariable (strsStream.str().c_str(), value) ) { cerr << "Error reading messages values" << endl; return 1; } //Metemos el valor en el array text_messages [i] = value; } }
But then, when I try from my logclnt.lib (in other function) to get a value from text_messages, it returns a empty string. However, text_messages is ok in my servmain function.
Any ideas?




Reply With Quote