Migrating to DataFlex 2021, Part 3
Lesson 12: Introduction – 64-bit
Part 3 of the Migrating to DataFlex 2021 series focuses on what 64-bit is, why it may be beneficial and what are the difficulties with 64-bit.
Creating a 64-bit version of an application can be easy or occasionally challenging. “64-bit” refers to the width of a memory address, which is 8 bytes. This is different from 32-bit where the memory address is 4 bytes. The width of a memory address is equal to the size of a pointer. With 64-bit memory addresses, more gigabytes of memory, and more data, can be addressed. In theory, a benefit of this is increased performance.
The main reason to move to 64-bit, however, is that there is a global movement towards using 64-bit, so it’s important to do the same to remain current. Doing so is more “future proof.” A DataFlex application must be 64-bit to communicate with other 64-bit applications, and most new software will be 64-bit. It is also safe to assume that in the future there will be 64-bit only operating systems. For these reasons, offering 64-bit applications is the more competitive choice.
Current Microsoft Windows operating systems are 64-bit but allow 32-bit applications to run on it by having them move their data through the WindowsOnWindows64 (WOW64) layer. 64-bit applications can store data right in memory without having to go through the WOW64 layer, which is potentially faster.
Why can 64-bit be difficult? There are two main reasons:
- A 64-bit pointer does not fit in a 32-bit data type, such as an integer.
- In 64-bit, moving a pointer to an integer would lead to pointer truncation, which would result in errors or crashes.
- Unfortunately, integer types are used to store pointer values in a lot of existing code in DataFlex applications. Historically, there was not a specific pointer type, so it originally didn’t matter. It will now be problematic in 64-bit.
- 32-bit and 64-bit do not mix.
- This means that dependencies must become 64-bit
Setting for Building and Running 64-bit
The Studio is 64-bit, but applications can still be built, run, and debugged as either 32- or 64-bit. The main toolbar in the Studio has a switch for 32- or 64-bit.
DEMONSTRATION
- The bit setting can be applied from the drop-down menu located on the main toolbar…
- …or by selecting ‘Project > Project Properties,’ clicking on the ‘Compiler’ tab, and then choosing either the ’32-bit’ or ’64-bit’ radio button under ‘Platform.’
- The executable name suffix can also be set there. By default it is blank for 32-bit, and set to ‘64’ for 64-bit. This will add the string “64” to the name of the resulting 64-bit executable file.
- For WebApps, it is advised to leave them both blank because the WebApp server points to a single executable location. These settings are saved per project in the .cfg file.
- Note that there is no Programs64 folder. The 32- and 64-bit deliverables both end up in the Programs folder. That is why they need to be distinguished by name, using the executable name suffix.
- Generally, a programs64 folder is not needed and not advised, but if wanted, one can be made by...
- Create a Programs64 folder, and copy the config.ws file to it
- Change this new config file to let the ProgramPath point to Programs64
- Duplicate the .sws file and rename it to <name>64.sws, and let it point to the config.ws file in Programs64
- Now when the workspace file is opened in the Studio, it compiles to the Programs64 folder, while the original still compiles to the Programs folder. All use the same sources.
- Compilation can also still be done outside of the Studio, using DfComp.exe. For compiling 32-bit, use the one in the ‘Bin’ folder, and for 64-bit use the one in the ‘Bin64’ folder. In DataFlex 2021 there is also a command-line compiler executable, called DfCompConsole.exe.
- The content can be seen if the manifest file is not embedded in the resulting executable. In the file, “x86” is for 32-bit and “amd64” is for 64-bit. Be aware that the 64-bit executable must go with a 64-bit manifest file, or the application will not run. Normally, this is not a concern because the Studio automatically writes out the correct one.