我有一個使用Microsoft SQLCE 3.5的Windows Mobile 6 ARMV4I的Visual Studio 2008 C++項目。當我初始化DBPROP
結構的VARIANT
組件(如下)時,我收到編譯器警告消息:C4366:一元'&'運算符的結果可能未對齊。當初始化SQL DBPROP結構時出現不對齊警告
#include <sqlce_oledb.h>
DBPROP prop = { 0 };
::VariantInit(&prop.vValue); // warning here
我可以添加__unaligned
投射到線,但因爲VariantInit
不採取__unaligned
,我得到另一個C4090警告。
我注意到DBPROP
定義* sqlce_oledb.h *包括對MIPS架構的指令包裝:
#if defined(MIPSII_FP) || defined(MIPSIV) || defined(MIPSIV_FP)
#pragma pack(push,8)
#endif
typedef struct tagDBPROP
{
DBPROPID dwPropertyID;
DBPROPOPTIONS dwOptions;
DBPROPSTATUS dwStatus;
DBID colid;
VARIANT vValue;
} DBPROP;
#if defined(MIPSII_FP) || defined(MIPSIV) || defined(MIPSIV_FP)
#pragma pack(pop)
#endif
所以,我可以將警示做這樣走:
#define MIPSIV
#include <sqlce_oledb.h>
#undef MIPSIV
但是,那感覺很髒。我的問題是:設計師是否忽略了ARM的包裝指令(意味着我應該做這個骯髒的,並聲稱是MIPS處理器)?或者,我應該沉默警告並忽略它嗎?或者,還有什麼我該做的?
感謝, PaulH
我都喜歡的建議1和2。謝謝。 – PaulH 2011-05-27 18:11:13