1. 程式人生 > >VC工程從Win32環境往Win64環境遷移的經驗總結('static_cast' (UINT)' to 'void (__cdecl CWnd::* )(UINT_PTR)')

VC工程從Win32環境往Win64環境遷移的經驗總結('static_cast' (UINT)' to 'void (__cdecl CWnd::* )(UINT_PTR)')

其次在工程屬性設定中作如下修改:

1.  在“C/C++”——“前處理器”中將WIN32改為_WIN64,並且放在最前面,這樣才確保連結的是64位的Windows SDK。

2.  在“連結器”——“高階”——“目標計算機”將“MachineX86(/MACHINE:X86)”改為“MachineX64 (/MACHINE:X64)”。

3.程式碼中有些地方需要修改:

(1)'static_cast' : cannot convert from'void (__cdecl CWindowTip::* )(UINT)' to 'void (__cdecl CWnd::* )(UINT_PTR)'   E:\2015prog\2-AutoTargetFDDetection64\WindowTip.cpp    128 1       AutoTargetDetection

解決辦法:

http://www.viva64.com/en/k/0011/

 searchfor the line "OnTimer(UINT " before compilation and replace it with"OnTimer(UINT_PTR ". 

原來的OnTimer定義:afx_msg void OnTimer(UINTnIDEvent);

改為:afx_msg void OnTimer(UINT_PTR nIDEvent);

一般來說,很多Windows API中型別為UINT的在64位出現編譯不通過,都需要將型別改為UINT_PTR。

(2)'GCL_HBRBACKGROUND' : undeclared identifier   E:\2015prog\2-AutoTargetFDDetection64\sizecbar.cpp       536 1     AutoTargetDetection

解決辦法: GCL_HBRBACKGROUND改為GCLP_HBRBACKGROUND