The C interface file

To make your C functions visible to the runtime system, you must define all the functions in the C interface file.

The C interface file is a C source file that defines the usrFunctions array. This array defines C functions that can be called from programs.

The last record of the usrFunctions array must be a line with all the elements set to NULL/0, to define the end of the list.

Each element of the usrFunctions array must be filled following members:
  1. The first member is the name of the function, provided as a (const char *) character string.
  2. The second member is the C function symbol, provided as an (int (*function) (int)) C function pointer.
  3. The third member is the number of parameters passed to the function through the runtime stack, provided as an (int).
  4. The fourth member is the number of values returned by the function, provided as an (int); use -1 to specify a variable number of arguments.

You typically do a forward declaration of your C functions, before the usrFunctions array initializer:

#include "f2c/fglExt.h"

int c_init(int);
int c_set_trace(int);
int c_get_message(int);

UsrFunction usrFunctions[]={
  { "init",         c_init,         0, 0 },
  { "set_trace",    c_set_trace,    1, 0 },
  { "get_message",  c_get_message,  1, 1 },
  { NULL,           NULL,           0, 0 }
};
Note that the UsrFunction structure contains an additional member, dedicated for internal use. If you experience compiler warnings because of un-initialized structure members, simply complete the C function definitions with a fifth zero value:
/* Avoids C compiler warnings because of un-initialized structure members */

UsrFunction usrFunctions[]={
  { "init",         c_init,         0, 0, 0 },
            /* member for internal use ---^ */
  ...