| Customize Help

Porting a 32-bit MIL application to MIL 64-bit

As of MIL 9.0, MIL supports 64-bit operating systems. For more details about supported operating systems, refer to the Requirements to run MIL section of Chapter 1: Introduction.

When porting an application to MIL 64-bit, there are certain modifications that must be made to your application's code. This section explains these changes and the circumstances under which they are required.

Modified functions

In the 64-bit version of MIL, there are actually two versions of the following functions:

The two versions of these functions differ in the expected data types of their parameters: one version has a Double suffix, and one version has an Int64 suffix (for example, MblobControlDouble() and MblobControlInt64()). The Double version of these functions should be used when the relevant parameter (typically the ControlValue parameter) requires a MIL_DOUBLE value and the Int64 version should be used when a MIL_INT value is required.

In C++ (*.cpp), the original functions are available as inline functions which will automatically call the appropriate version of the function depending on the type of parameter received. No change to your source code should be required if you are compiling your 64-bit MIL application in C++.

In C (*.c), the original functions are actually macros that call the most typically required version of the function. This means that if you are compiling your MIL application in C, only minor modifications to your code will be necessary. Compiler warnings will be produced if you pass a function a double value where an integer is expected; in this case, you will need to explicitly change this function call to the proper version of the function.

Retrieving a pointer to a modified function

Advanced users might want to retrieve a pointer to one of the modified functions. In this case, only the Double or Int64 version should be used, since the original function is actually a macro or an overloaded function. For example, you must retrieve a pointer to MmetSetPositionDouble() or MmetSetPositionInt64(), and not MmetSetPosition().

Note that when retrieving pointers to functions, the following are also affected: MimArith() and MimArithMultiple(). For these functions, a Double version also exists; you must use it instead of the original.

Void pointers

Most MIL functions have parameters of a fixed data type. However, there are some functions, predominantly M...Inquire() and M...GetResult() functions, where one (or more) of their parameters is a void pointer. The expected data type for these void pointer parameters is determined in one of the two ways as described in the Void pointers subsection of the MIL custom data types, void pointers, extensions, and portability functions section earlier in this chapter.

For the 64-bit version of MIL, you will have to use the required custom data types documented as of MIL 9.0. For example, the following code for the 32-bit version of MIL:

long SizeX;
MbufInquire(BufId, M_SIZE_X, &SizeX);

Should be changed for the 64-bit version of MIL as follows:

MbufInquire(BufId, M_SIZE_X, &SizeX);


When using void pointers, it is possible to make a mistake and pass a value with the wrong data type. These errors can cause unexpected behavior such as: stack corruption, array overflow, uninitialized returned data, and segmentation faults. To ease the transition from 32-bit to 64-bit, use the MIL M_MIL_USE_SAFE_TYPE extension. It will help you find calls to functions whose prototypes have been modified. By default, the M_MIL_USE_SAFE_TYPE extension is enabled when compiling in debug mode.

For more information about the M_MIL_USE_SAFE_TYPE extension, see the MIL custom data types, void pointers, extensions, and portability functions section earlier in this chapter.

Note that this extension is not supported under Linux.

Project processor definitions

When porting an application to MIL 64-bit, you must verify that your project processor definitions (PPDs) include WIN64 and _AMD64 (these PPDs appear in the Properties page of your application). Your application will not compile if it is missing WIN64 and _AMD64.

Not supported under Linux.