ILOG CPLEX 11.0 User's Manual > Languages and APIs > ILOG CPLEX Callable Library > ILOG CPLEX Programming Practices > Portability

ILOG CPLEX contains a number of features to help you create Callable Library applications that can be easily ported between UNIX and Windows 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 such routines as 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 lpex4.c and Example: Callable Library Message Channels.

CPXCHARptr, CPXCCHARptr, and CPXVOIDptr

The types CPXCHARptr, CPXCCHARptr, 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*, const char*, or void*.

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. Callable Library Routines for Message Channels 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.