The C Interface has been created for you to call C functions, which come in shared / static libraries, from Lycia 4GL application code. Using the C interface, you can include standard or custom C libraries in your application using the wrapper functions.
Function parameters and returned values are managed on the runtime stack using pop and push operations. Ensure you pop and push the exact number of parameters and returned values expected by the caller to avoid a fatal stack error at runtime.
To include the C code in the 4GL program, do the following:
Ensure that the functions defined in your C Interface do not conflict with existing program functions. Conflicts can result in compiler or runtime errors.
Step 1. Add the C source files, header files, and ESQL/C files to your Workspace:
Step 2. Create a static C library in your project by right-clicking the Project context menu and selecting the Create New Static C Library option:
Step 3. Name the library and press Enter:
Your created library will now appear as a part of the project in FGL Project Explorer:
Also, it will receive its own .fgltarget file (displayed in the source folder of your program in the Workpace) and will therefore become a build target.
Step 4. Right-click the library, select Add Existing File, and then - Add C Source File:
Step 5. In the dialog that will appear in the upper part of the window, find a file you need to add to the library, and select it:
Step 6. Right-click the program, and select the Add Existing Library option:
Step 7. In the dialog that will open in the upper part of the window, select the library / libraries by ticking their boxes, and click OK:
After that, right-click your program and select the Build/Deploy option to link all the resources.
To use complex data files in a C Interface, include C header files (.h) that contain the definitions of C structures.
For compiling a program with C Interface using the data types such as DECIMAL, DATETIME, INTERVAL, BYTE, or TEXT, you need IBM® Informix® ESQL/C data type structure definitions such as dec_t, dtime_t, intrvl_t, as well as macros like TU_ENCODE(). These definitions are unnecessary if you use standard C types, such as short, int, or char[].
The definition of the ESQL/C structures like dec_t are provided in individual header files, under the $LYCIADIR/include/ directory: decimal.h, datetime.h, locator.h.