引擎中的每個(gè)工程均以靜態(tài)庫(kù)方式鏈接到最后的exe. 代碼中包含有靜態(tài)類成員,第一次運(yùn)行正常,后面不知什么原因, 這些靜態(tài)類成員不會(huì)被初始化, 在 crtexec.c 的CRT 初始化全局類成員函數(shù)
static void __cdecl _initterm (
#endif /* CRTDLL */
_PVFV * pfbegin,
_PVFV * pfend
)
{
/*
* walk the table of function pointers from the bottom up, until
* the end is encountered. Do not skip the first entry. The initial
* value of pfbegin points to the first valid entry. Do not try to
* execute what pfend points to. Only entries before pfend are valid.
*/
while ( pfbegin < pfend )
{
/*
* if current table entry is non-NULL, call thru it.
*/
if ( *pfbegin != NULL )
(**pfbegin)();
++pfbegin;
}
}
這個(gè)函數(shù)會(huì)初始化所有鏈接到exe中的全局函數(shù)構(gòu)造, 跟蹤這個(gè)地方, 發(fā)現(xiàn),只有1個(gè)lib中的能被正確調(diào)用,但是出問(wèn)題的那個(gè)lib中所有構(gòu)造都不能被調(diào)用. 嘗試調(diào)整編譯順序無(wú)果
唯一的方法只有修改架構(gòu)為在winmain內(nèi)進(jìn)行構(gòu)造
如果有這方面調(diào)試經(jīng)驗(yàn)的同學(xué)可以回帖,謝謝