Lisp HUG Maillist Archive

Calling a created foreign callback

Is there a way, in the FLI, to call a C function that is obtained at
runtime? For example, here is some (similar) C code in a DLL I'm using
at work:

typedef int (*string_compare_f )(const char *s1, const char *s2);

// returns either strcmp or stricmp based on global settings
string_compare_f get_string_compare();

I'd like to call get_string_compare() once at program startup, and
then use the returned function throughout the lifetime of the FLI
interface. Is this possible or do I have to know the function at
compile time? I think, in this case, even using an EVAL around
DEFINE-FOREIGN-FUNCTION at runtime would be alright.

Jeff M.

-- 
http://www.retrobyte.org
mailto:massung@gmail.com


Re: Calling a created foreign callback

On Thu, 23 Dec 2004 11:22:44 -0700, Jeff Massung <massung@gmail.com> wrote:

> Is there a way, in the FLI, to call a C function that is obtained at
> runtime? For example, here is some (similar) C code in a DLL I'm
> using at work:
>
> typedef int (*string_compare_f )(const char *s1, const char *s2);
>
> // returns either strcmp or stricmp based on global settings
> string_compare_f get_string_compare();
>
> I'd like to call get_string_compare() once at program startup, and
> then use the returned function throughout the lifetime of the FLI
> interface. Is this possible or do I have to know the function at
> compile time? I think, in this case, even using an EVAL around
> DEFINE-FOREIGN-FUNCTION at runtime would be alright.

Isn't FLI:DEFINE-FOREIGN-FUNCALLABLE what you want?

  <http://www.lispworks.com/reference/lw44/FLI/html/fli-72.htm>

Cheers,
Edi.


Re: Calling a created foreign callback

> Isn't FLI:DEFINE-FOREIGN-FUNCALLABLE what you want?

Beautiful. Thanks :)

Jeff M.

-- 
http://www.retrobyte.org
mailto:massung@gmail.com


Updated at: 2020-12-10 08:54 UTC