stl的常用結構有 vector、list、map等。
今天碰到需要在不同dll間傳遞這些類型的參數,以void*作為轉換參數。
比如 DLL2 的接口 add(void*pVoid);
1.在DLL1中調用該接口,
struct st_headerTerminalRes
{
st_headerTerminalRes(){id=0;}
int id;
int type;//restype 1=mc 2=camera
int resId;
int headerId;
};
typedef vector<st_headerTerminalRes> ltHeaderres;
ltHeaderres ltRes;
add((void*)(<Res));
2.在DLL2中
ltHeaderres ltRes = *(ltHeaderres *)pVoid; 在此處報錯
如果DLL1和DLL2都是release或都是debug版本,調用是不會報錯的。
而本人用的是debug的DLL1,調用release的DLL2。導致在該行報錯。
所以在DLL互相調用的時候,一定要統一版本。混合調用很容易出現奇怪的問題。