Calling program functions from C

It is possible to call an program function from a C function, by using the fgl_call macro in your C function, as follows:
fgl_call ( function-name, nb-params );

function-name is the name of the program function to call, and nb-params is the number of parameters pushed on the stack for the program function.

function-name must be written in lowercase letters; The fglcomp compiler converts all program functions names to lowercase.

The fgl_call() macro is converted to a function that returns the number of values returned on the stack. The program function parameters must be pushed on the stack before the call, and the return values must be popped from the stack after returning.

#include <stdio.h>
#include <f2c/fglExt.h>
int c_fct( int n )
{
   int rc, r1, r2;
      pushint(123456);
   rc = fgl_call( fgl_fct, 1 );
   if (rc != 2) ... error ...
   popint(&r1);
   popint(&r2);
   return 0;
}