[cffi-devel] Re: calling a function of the same name from two DLLs
Nikodemus Siivola
nikodemus at random-state.net
Mon Dec 18 10:29:41 UTC 2006
"Jack Unrue" <jdunrue at gmail.com> writes:
> Hello, CFFI folks. What are the implications of declaring two foreign functions,
> each foreign name being the same but which are implemented in two separate
> DLLs? The specific case I have in mind is the Win32 function DllGetVersion,
> which can return different meta-data for comctl32.dll vs. shell32.dll.
> (load-foreign-library "comctl32.dll")
>
> (defcfun
> ("DllGetVersion" comctl-dll-get-version)
> HRESULT
> (info :pointer))
>
> (load-foreign-library "shell32.dll")
>
> (defcfun
> ("DllGetVersion" shell-dll-get-version)
> HRESULT
> (info :pointer))
For SBCL 1.0 at least both will be backed by the same foreign function,
namely the first one to be loaded.
The Right Thing, I believe, would be something like
(load-foreign-library "foo.dll" :name :foo)
(defcfun ("FooFun" foo-fun :library :foo) ...)
which would not be too hard to support on the SBCL end of things at least.
Cheers,
-- Nikodemus Schemer: "Buddha is small, clean, and serious."
Lispnik: "Buddha is big, has hairy armpits, and laughs."
More information about the cffi-devel
mailing list