Understanding C-Extensions

With C-Extensions, you can bind your own C libraries in the runtime system, to call C function from the application code. This feature allows you to extend the language with custom libraries, or existing standard libraries, by writing some 'wrapper functions' to interface with the Genero language.

On regular platforms, C-Extensions are implemented with shared libraries, that will be loaded by the fglrun program on demand.

Note: Platforms such as iOS mobile devices deny to load shared libraries. In this case, you must re-link the virtual machine. For more details, see Implementing C-Extensions for GMI.

Function parameters and returned values are passed/returned on the runtime stack, using pop/push functions. Be sure to pop and push the exact number of parameters/returns expected by the caller; otherwise, a fatal stack error will be raised at runtime.

In order to use a C-Extension in your program, you typically specify the library name with the IMPORT instruction at the beginning of the module calling the C-Extension functions. The compiler can then check for function existence and the library will be automatically loaded at runtime.

Note: