Hi Teach, this is not the exact code ( the company I'm working for is very strict about releasing code and it a small part of a very large code ). By the way I only get link errors on release mode where the code is optimized.
If I include debug information everything is fine. When building the release version ( no debug info ) I've tried using the option -O1 lowest optimisation, plus added volatile qualifier on the variables mentioned below but I still have link errors.
Okay here goes, I've got this variables declared in a CPP file.
typedef struct { int32 id; const char *errStr; } EventStruct;
static EventStruct *gEventTable = NULL;
static int gSize = 0;
static bool gEchoOn = false;
The file also contains an inline class which access the variables mentioned above which inherits from an abstract class which is on another separate file.
class Abstract : public Concrete
{
public :
.
.
void Access_g_EventTable()
{
if ( gEventTable )
{
( do what ever here also manipulate or
access gSize and gEcho here )
}
}
}
Now there is also a stand alone function which initialises the mentioned variable. This is declared as extern in another file where EventStruct is created. After EventStruct is created this function is called passing in the newly created EventStruct.
void setVarialbes( EventStruct* eventTable, int size )
{
gEventTable = eventTable;
gSize = size;
}
In NT ( This code is designed to run on multiple OS ) everything is OK (Debug and Release version ), but in Solaris I get a link error ( only when debugging is off ) saying that the variable gEventTable, gSize and gEchoOn is unreferenced in the file where they were declared.
Sorry if this is a bit long and I could not give all of the code.
|