On Tue, Nov 6, 2012 at 12:31 AM, Peter Enerccio <enerccio@gmail.com> wrote:
I am using this kind of macro:

#define DEFUN( name, argcount, fpointer) do { \
    cl_def_c_function(c_string_to_object(name), \
            (cl_objectfn_fixed)fpointer, \
            argcount); \
    } while (0)

This code is wrong. If you want to create a function with a variable number of arguments, the function F should have signature

cl_object F(cl_narg narg, ...)

and be defined with

ecl_def_c_function_va(symbol, F)

If you instead want to use a function with a fixed number of arguments (say 2), then the signature should be

cl_object F(cl_object arg1, cl_object arg2)

and be defined with

ecl_def_c_function(symbol, F, 2)

But this is strongly discouraged and not future proof: write the code in lisp and let ECL compile it.


Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)