Open System Services Programmer's Guide
Converting 32-Bit Applications to 64-Bit Applications
The advantages of 64-bit applications are:
• The string-manipulation and file and socket I/O APIs available for 32-bit applications that
access 64-bit data segments are very limited. There are many more string-manipulation and
file and socket I/O APIs available for 64-bit applications, which access 64-bit data segments.
See “New OSS String Manipulation Functions” (page 302) and “File and Socket I/O APIs
32-Bit Support for 64-Bit Segments” (page 302) for details of the available string-manipulation
and file and socket I/O APIs available for 64-bit data segments in 32-bit applications.
• Access to 64-bit data segments from 32-bit applications requires the use of proprietary APIs.
Porting an existing 64-bit application would be much easier than converting the application
to the ILP32 data model with 64-bit segment access.
The following topics in this section provide the required steps to convert 32-bit applications to
64-bit applications.
Step 1: Identify Programs that Need to be Compiled in the LP64 Data Model
The first step in converting 32-bit applications to 64-bit applications is to identify the code that
would benefit from 64-bit computing. See “Features of 64-Bit Support” (page 285) for the advantages
of 64-bit applications.
64-bit main programs can only call 64-bit DLLs or neutral DLLs. Therefore, DLL providers for 64-bit
applications must transition their DLLs to the LP64 or neutral data model.
Step 2: Identify Non-Portable Constructs
You can use the following tools to find non-portable code when transitioning 32-bit applications
to the LP64 data model:
• NonStop C/C++ compilers
• CodeCheck – developed by ABRAXAS Software
• Open Systems Portability Checker (OSPC) – developed by Knowledge Software
• FlexeLint – developed by Gimpel Software
Step 3: Using the C/C++ Compiler to Identify Needed Source Code Changes
The C/C++ compiler has the ability to detect a number of 64-bit porting issues. For some issues,
the compiler emits a diagnostic by default. For example, any direct assignment from a 64-bit pointer
to a 32-bit pointer results in the error:
error(611): a value of type “long-pointer-type” cannot be
assigned to an entity of type “short-pointer—type”
In addition, the C/C++ compiler provides a feature to enable additional warnings to be emitted.
These warnings detect valid C/C++ code that potentially can behave in an “unexpected” manner
when code designed for the ILP32 data model is compiled using the LP64 data model. This feature
is controlled by the following command line options.
• Windows and OSS environment: -Wmigration_check=32to64
• Guardian environment: migration_check 32to64
An example of one of these diagnostics is: Any conversion (using either a cast or a direct
assignment) from a long to an int results in the warning:
warning(2412): 64 bit migration: type conversion may truncate value
Another example is: Any conversion from a pointer to a long to a pointer to an int or from a
pointer to an int to a pointer to a long results in the warning:
warning(2414): 64 bit migration: type conversion may cause target of
pointers to have a different size
Converting 32-Bit Applications to 64-Bit Applications 307