Thank you, Allin
If I do not mistake the thing
I want to try use libc only
so, hopefully, there will
be no problems with include
Oleh
15 жовтня 2017, 02:06:10, від "Allin Cottrell" <cottrell(a)wfu.edu>:
On Sat, 14 Oct 2017, Sven Schreiber wrote:
> Am 14.10.2017 um 15:55 schrieb > oleg_komashko(a)ukr.net:
>> Dear All,
>> Is it possible to compile
>> gretl at own pc with new
>> c functions on Linux, e.g.
>> Ubuntu?
>
> Do you really mean just a new C function, or do you mean a new
> built-in hansl function which uses compiled C code for execution?
>
> The first case is probably relatively easy, you just have to make
> sure that the new function is actually picked up and gets included
> into libgretl. About the second case -- well that's the secret of
> the masters I guess...
>
> No seriously, it's a very useful question. (But I would like to
> know myself.)
Yes, a good question.
Adding a new C function to libgretl is just a matter of... doing
just that. You write a function in C, stick into an appropriate .c
file in lib/src, and -- if it's supposed to be publicly available
(and I don't suppose there would be much point otherwise) -- also
add a declaration of the function to the corresponding .h header
file.
Making such a function accessible via hansl requires working with
the C files genparse.h, genlex.c and geneval.c (in lib/src).
genparse.h is where you insert a unique internal identifier for the
function (e.g. F_NUMHESS), putting it into the functions "enum" in
the right place. Scanning the existing enum one should get an idea
of what "the right place" means. Basically: how many arguments does
the new function take? -- other than that it doesn't much matter
where it goes.
genlex.c is where you create a mapping from the function's internal
identifier (e.g. F_NUMHESS) to the name under which users can call
it (e.g. "numhess"). Plenty of examples available there. The exact
position of the new entry doesn't matter.
geneval.c is where you actually "hook up" the hansl function to its
C back-end. A hansl-function must have an entry in the function
named "eval". This entry should (usually) do some basic
type-checking on the arguments provided by the user, then hand off
to an implementer function. The best way to grok this is to follow
the path of execution for a hansl function that you're familiar
with. Ideally you want to find an existing function that is as
similar as possible to your new one, in terms of (a) what it
returns, and (b) the type of arguments it expects.
I (or Jack) can provide more detail as needed, but that's the basic
overview.
Allin
_______________________________________________
Gretl-devel mailing list
Gretl-devel@lists.wfu.eduhttp://lists.wfu.edu/mailman/listinfo/gretl-devel