, . / undefined, , , ( ). , , second.c Initialize() ctor run . , , .
, , ( ) . init-order , , ( concurrency). -
/ (main.c)/
#include CommonDat { int i;
public:
const int GetI() { return i;}
void SetI(int newI) { i = newI; }
void incI()
{
AcquireSomeLock();
i++;
ReleaseTheLock();
}
}
CommonDat g_CommonDat;
CommonDat* getCommonDat() { return &g_CommonDat; }
int main(void)
{
printf("%d",getCommonDat()->GetI());
}
, ( c'tors).
(: C, ++. - ++, ).
source
share