Variable Size Changes

Before recompiling your code, closely examine parameters, variables, and return values declared as type int in your C/C++ code. In C/C++ code the size of an int depends on the system and/or compiler. Win16 defined an int to be 16 bits, or the same as a short int or short. In Microsoft Excel the short int code used with REGISTER() is "H" (signed short int) or "I" (unsigned short int). Win32 defines an int to be 32 bits, or the same as a long int or long, and the Microsoft Excel registration code is "J".

Microsoft Excel does not support a system-dependent int parameter or return value type and will have a problem with carelessly written Win16 code that is recompiled for Win32. Plain int parameters and return values are expanded to 32 bits, which effectively changes the registration type code from "H" to "J". Calling an incorrectly declared procedure may result in incorrect results or a protection fault. There are three solutions to this problem:

1. Leave the C/C++ code alone (it still uses system-dependent plain int) and conditionalize your calls to REGISTER() to be aware of the current operating system platform. On Win16 use 16-bit "H" and "I" codes, and on Win32 use the 32-bit "J" value. An example of how to do this would be:

=IF(Win16)
=   REGISTER("mydll.dll","StandardFile","PIGGG")
=ELSE()
=   REGISTR("mydll.dll", "StandardFile","PJGGG")
=END.IF()

2. Leave the XLM code alone and instead clean up the C/C++ variable declarations. All int parameters and return values are modified to be either a short int or a long int as required. The same REGISTER() type code can then be used on either platform.

3. Use conditional compilation to declare the appropriate C/C++ variable declarations. Change your XLM code to use the appropriate parameter sizes for the appropriate platform. This is somewhat of a combination of options 1 and 2.