When using the DllFunction class, it is necessary to specify the type and value of each function parameter. A C programmer typically deals with a much larger set of data types than does an IMLPlus or Java programmer. This is because the C programming language provides the #define preprocessor directive and the typedef statement that allow aliases to be created for the fixed set of primitive data types. When calling a C function from an IMLPlus program, it is necessary to map the C data type expected by the function into an equivalent Java data type. ("Equivalent" in this context usually means "same bit width".) There are several issues to be aware of:
If a C function expects an unsigned integer for a particular parameter, you must pass the function the corresponding Java signed integer type. For example, if a C function expects a parameter of type "unsigned int", you must pass it a Java int variable.
If a C function expects a pointer for a particular parameter, you must pass the function a Java array. The type of the array must correspond to the bit width expected by the C function. For example, if a C function expects a parameter of type "double *", you must pass it a Java array of type double. A numeric matrix variable can be passed to a C function that expects a parameter of type "const double *".
An IMLPlus program cannot directly call a C function that requires a struct for a parameter. You can, however, write an intermediary C function that the IMLPlus program can call that in turn calls the C function requiring the struct parameter.
In many cases, IMLPlus is able to convert from one data type to another automatically. This is often very useful when calling a C function. For example, if a C function expects a particular parameter to be an int but your IMLPlus program has the value in a scalar numeric matrix, you can call the NextArgIsInt32 method and pass it the matrix variable. IMLPlus will automatically convert from the matrix data type to the int data type. For details on type conversion in IMLPlus, see Type Conversion and Casting.
Please refer to the following topics:
Pointer Types for Read-Only Null-Terminated Strings
Passing a Numeric Matrix to a C Function
Passing a Character Matrix to a C Function
A good source of example code that demonstrates the use of the DllFunction class to call C functions is the IMLPlus user-interface modules. See Overview of IMLPlus Module Reference for instructions on how to view the source code to these IMLPlus modules.