Portability

ILOG CPLEX contains a number of features to help you create Callable Library applications that can be easily ported between UNIX and Windows 95 and NT (that is, Win32) platforms.

CPXPUBLIC

All ILOG CPLEX Callable Library routines except CPXmsg() have the word CPXPUBLIC as part of their prototype. On UNIX platforms, this has no effect. On Win32 platforms, the CPXPUBLIC designation tells the compiler that all of the ILOG CPLEX functions are compiled with the Microsoft __stdcall calling convention. The exception CPXmsg() cannot be called by __stdcall because it takes a variable number of arguments. Consequently, CPXmsg() is declared as CPXPUBVARARGS; that calling convention is defined as __cdecl for Win32 systems.

Function Pointers

All ILOG CPLEX Callable Library routines that require pointers to functions expect the passed-in pointers to be declared as CPXPUBLIC. Consequently, when your application uses the ILOG CPLEX Callable Library routines CPXaddfuncdest(), CPXsetlpcallbackfunc(), and CPXsetmipcallbackfunc(), it must declare the user-written callback functions with the CPXPUBLIC designation. For UNIX systems, this has no effect. For Win32 systems, this will cause the callback functions to be declared with the __stdcall calling convention. For examples of function pointers and callbacks, see Example: Using Callbacks and Example: Using the Message Handler.

CPXCHARptr and CPXVOIDptr

The types CPXCHARptr and CPXVOIDptr are used in the header file cplex.h to avoid the complicated syntax of using the CPXPUBLIC designation on functions that return char or void pointers.

File Pointers

File pointer arguments for Callable Library routines should be declared with the type CPXFILEptr. On UNIX platforms, this practice is equivalent to using the file pointer type. On Win32 platforms, the file pointers declared this way will correspond to the environment of the ILOG CPLEX DLL. Any file pointer passed to a Callable Library routine should be obtained with a call to CPXfopen() and closed with CPXfclose(). Callable Library routines with file pointer arguments include CPXsetlogfile(), CPXaddfpdest(), CPXdelfpdest(), and CPXfputs(). Handling Message Channels: Callable Library Routines discusses most of those routines.

String Functions

Several routines in the ILOG CPLEX Callable Library make it easier to work with strings. These functions are helpful when you are writing applications in a language, such as Visual Basic, that does not allow you to dereference a pointer. The string routines in the ILOG CPLEX Callable Library are CPXmemcpy(), CPXstrlen(), CPXstrcpy(), and CPXmsgstr().

ILOG CPLEX-Allocated Memory

The Callable Library read routines CPXreadcopyprob(), etc., return pointers to memory allocated by the Callable Library. The Callable Library routine CPXfree() frees these pointers. On UNIX systems, it is acceptable, but not recommended for portability reasons, to use the system call free().

For more complete access to ILOG CPLEX memory management, you also have the routines CPXmalloc() and CPXrealloc(). However, you are not required to use these two routines in order to have correctly functioning Callable Library applications.


Previous Page: Callbacks  Return to Top Next Page: FORTRAN Interface