引擎中的每個工程均以靜態庫方式鏈接到最后的exe. 代碼中包含有靜態類成員,第一次運行正常,后面不知什么原因, 這些靜態類成員不會被初始化, 在 crtexec.c 的CRT 初始化全局類成員函數
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;
}
}
這個函數會初始化所有鏈接到exe中的全局函數構造, 跟蹤這個地方, 發現,只有1個lib中的能被正確調用,但是出問題的那個lib中所有構造都不能被調用. 嘗試調整編譯順序無果
唯一的方法只有修改架構為在winmain內進行構造
如果有這方面調試經驗的同學可以回帖,謝謝