Well, I’ve got an intersting problem. Still using 6.1a (don’t know
if that matters) porting working code from Watcom (Q4).
I’ve got a class that is performing a sanitiy check on a static
array. The problem is the constructor is being executed before the
static array initialized from a constant array.
Like I said, the code was from Q4/Watcom and working there. Here
are some snipets
in the .cc
#define LOOKUP_REFERENCE(table,scope) {table, scope, table ## _SIZE, #scope}
LOOKUP_ACCESS_TABLE_T StringLookup::stringsInScope[] =
{ // the order of these must match SCOPE_T
LOOKUP_REFERENCE(PATIENT_ALARM_PARM_T_STRING, SCOPE_PATIENT_ALARM_PARM),
LOOKUP_REFERENCE(PATIENT_ALARM_STATE_T_STRING, SCOPE_PATIENT_ALARM_STATE),
LOOKUP_REFERENCE(EQUIP_ALARM_EQTYPE_T_STRING, SCOPE_EQUIP_ALARM_EQTYPE),
LOOKUP_REFERENCE(EQUIP_ALARM_ID_T_STRING, SCOPE_EQUIP_ALARM_ID),
LOOKUP_REFERENCE(EQUIP_ALARM_STATE_T_STRING, SCOPE_EQUIP_ALARM_STATE),
LOOKUP_REFERENCE(SCOPE_DS_ACTION_3_LINE_T_STRING, SCOPE_DS_ACTION_3_LINE),
LOOKUP_REFERENCE(NO_ACTIVITY_LOOKUP, SCOPE_NO_ACTIVITY)
};
and of course
StringLookup::StringLookup()
{
for (int scope=0; scope < tableSize; scope++)
{
if (stringsInScope[scope].scope != scope)
{
printf(“scope name %s enum %d does not match index %d\n”,
stringsInScope[scope].scopeName,
stringsInScope[scope].scope, scope);
}
for (int i = 0; i < stringsInScope[scope].numElements; i++)
{
LOOKUP_T* lookup = stringsInScope[scope].lookupTable;
if (lookup_.enumId != i)
{
printf(“scope %s enum %d does not match index %d\n”,
stringsInScope[scope].scopeName, lookup.enumId, i);
}
}
}
Any wisdom on this one??
I’ve tried changing the scope of the member variable to a global
with no luck there. As well putting the definition into the class
definatition does not help as it creates a declaration loop inside
header files.
Any help would be greatfully appreciated!
Tom_