简体   繁体   English

将C ++代码从32位转换为64位

[英]Transformation of C++ code from 32 bit to 64 bit

I am using VS 2008. I compile my C++ code in 32 bit compiler. 我正在使用VS2008。我在32位编译器中编译C ++代码。 I am using DialogBoxParam to create a GUI and its working fine. 我正在使用DialogBoxParam创建一个GUI及其工作正常。 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' . 但是相同的代码在64位编译器中进行了编译,但出现错误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 . 如果检查DLGPROC参考,您将看到它应返回INT_PTR而不是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. 您遇到的问题是由于BOOLint的类型别名,在使用Visual Studio编译器的32位和64位平台上, BOOL都是32位。 INT_PTR on the other hand is 64 bits on 64 bit systems, making you have a mismatch in return type. 另一方面, INT_PTR在64位系统上为64位,这会使返回类型不匹配。

Change the return type of the dialog function to the correct INT_PTR and it should work on both 32 and 64 bit systems. 将对话框函数的返回类型更改为正确的INT_PTR ,它应该在32位和64位系统上可以工作。

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. 由于您是在32位计算机上编译的,因此迁移到64位计算机的常见问题是long和int在32位平台上都是32位,而long是64位而int是32位。 64位平台。 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. 您需要检查涉及的实际处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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