[Prev][Next][Index][Thread]
Re: FFI question #2: Getting the address of a C function
-
To: info-dylan@ai.mit.edu
-
Subject: Re: FFI question #2: Getting the address of a C function
-
From: oodl@my-deja.com
-
Date: Thu, 27 Jul 2000 18:15:01 -0400 (EDT)
-
Organization: Deja.com - Before you buy.
-
References: <8la6bs$q4p$1@nnrp1.deja.com> <200007221833.OAA12298@life.ai.mit.edu>
-
Xref: traf.lcs.mit.edu comp.lang.dylan:12517
With the info that Gary supplied, I was able to write a macro to get the
address of a C function. It seems to compile and link fine.
use dylan-direct-c-ffi; // in fuctional-dylan library
define macro address-of-c-function
{ address-of-c-function (?c-function-name:expression, import:
?import:expression) }
=> { make(<c-function-pointer>,
address: primitive-wrap-machine-word
(primitive-cast-pointer-as-raw
(%c-variable-pointer(?c-function-name,
?import)))); }
{ address-of-c-function (?c-function-name:expression) }
=> { make(<c-function-pointer>,
address: primitive-wrap-machine-word
(primitive-cast-pointer-as-raw
(%c-variable-pointer(?c-function-name, #f)))); }
end;
It can be used as follows:
address-of-c-function("foo", import: #t);
Sent via Deja.com http://www.deja.com/
Before you buy.
References: