Find the variables whose datatypes needs to be upgraded in order to support 64-bit and change them as applicable.
-
Longptr
In the 32-bit platform, longptr is the same as long; you can continue using long wherever longptr is required in 32-bit applications. In 64-bit applications, however, using long to hold longptr variables will lead to data truncation from 8 bytes to 4 bytes, or memory corruption if you pass a long ref variable when a longptr ref is required. If you want to migrate to 64-bit, use longptr wherever required as it does no harm to 32-bit.
Since PowerBuilder does not have a datatype corresponding to the C++ pointer type, and there are no pointer operations in PowerBuilder, longptr is not a full-fledged PowerBuilder datatype. You can use it to hold/pass window handles, database handles, and other objects that are essentially memory addresses. Doing complex operations on longptr type might not work. If you want to represent/compute 8-byte long integers, use longlong.
-
LongLong
To take advantage of the 64-bit architecture, you can change your Long datatype variables to LongLong. Because this datatype is for 64-bit signed integers, from -9223372036854775808 to 9223372036854775807.
Keep in mind that LongLong continues using literals as for integers, but longer numbers are permitted.
-
Using 1-byte structure member alignment in external function (read more)
When you use a structure or structure array as parameters to external function in the older versions of PowerBuilder, the structure member alignment was one byte. However, the default alignment is 8 bytes on Windows platform, which means that most (if not all) Windows standard APIs use this value to align arguments with structure members. This will cause a mismatch between Windows APIs and PB applications in PowerBuilder 12.5 and earlier versions. A well adopted solution to this issue was to add some bytes within PowerBuilder structures manually to fill those gaps. Such gap filling can be complex and error-prone if involving complex nested structures. And what is worse, this solution fails with the introduction of 64-bit application development in PowerBuilder because the number of bytes you have to fill may be different between 64-bit and 32-bit applications. This was the major reason to make this change in PowerBuilder. The default structure member alignment for Windows APIs and Visual C++ is now on an 8 byte boundary. The structure member alignment was changed to 8 bytes for both 64-bit and 32-bit applications. This was an intentional change so that you can now call Windows APIs easier and use the same code for both 64-bit and 32-bit applications.
Customers can switch to the old behavior in two ways:
-
Check "Use 1-byte structure member alignment in external function" (or set UseZp1=1 in [pb] section, pb.ini, the results are the same). The effect is global with this setting changed. To make this work at runtime, please remember to deploy your pb.ini file with your application.
-
Add "progmapack(1)" external function’s declaration, like this: FUNCTION int STLAREGIO ( ref struckfzrechnerneu struckfz ) LIBRARY "KFZSS.DLL" alias for "STLAREGIO;Ansi" progma_pack(1)
progmapack(1) is 1-byte alignment, progmapack(8) is an 8-byte boundary (double-word) alignment. These settings only affect an external function declaration’s alignment usage.
-