简体   繁体   中英

Transformation of C++ code from 32 bit to 64 bit

I am using VS 2008. I compile my C++ code in 32 bit compiler. I am using DialogBoxParam to create a GUI and its working fine. But the same code is compiled in 64 bit compiler, I get error that error C2664: 'DialogBoxParamA' : cannot convert parameter 4 from 'BOOL (__cdecl *)(HWND,UINT,WPARAM,LPARAM)' to 'DLGPROC' . Kindly help me with this

If you check eg this DLGPROC reference you will see that it should return INT_PTR and not BOOL .

The problem you have stems from the fact that BOOL is a type-alias of int which is 32 bits on both 32- and 64-bit platforms using the Visual Studio compiler. INT_PTR on the other hand is 64 bits on 64 bit systems, making you have a mismatch in return type.

Change the return type of the dialog function to the correct INT_PTR and it should work on both 32 and 64 bit systems.

Since you are compiling on a 32 bit machine, the usual problem with moving to a 64 bit machine is that a long and an int are both 32 bits on a 32 bit platform, while a long is 64 bits and an int is 32 bits on the 64 bit platform. If you are using pointer referencing or byte manipulation, this can cause difficulties in the call to your functions.

You need to examine the actual processing involved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM