Excel-callable DLL [RE: CFORTRAN for cygwin/egcs?]
Wed Mar 31 19:45:00 GMT 1999
On Tue, 16 Mar 1999, Billinghurst, David (RTD) wrote:
> Yes please. I'd love an example of a DLL callable from Excel
I won't get a chance to make an example for a while, but here's the
1. You need to tell the compiler that the functions need to use the
stdcall calling convention and not the default cdecl. There are two
ways to do it:
a. You can attach an __attribute__((stdcall)) (or WINAPI or STDCALL
which are macros that expand to the attribute) to each exported
function. This is not possible in g77, so you need to use b.
b. Compile all the to-be-turned-into-DLL files with -mrtd, which tells
the compiler to use stdcall calling convention for all the functions.
In most cases, (b) is the simpler option since you don't need to modify
the source code at all.
2. if you're using Cygwin GCC (no -mno-cygwin), then you need to do supply
"special" entry point so that Cygwin DLL is initialized correctly when
it's loaded by Excel etc. Also, you need to make sure cygwin1.dll is in
your path when Excel loads your DLL.
$ dllwrap --entry __cygwin_noncygwin_dll_entry@12 [rest of the options]
I believe the examples in the dllhelpers package describe the rest.
BTW, this is exactly the same mechanism for creating a Java JNI using
Cygwin DLL. (1) is taken care of automatically since Java headers define
a macro that essentially makes the calling convention stdcall. See my
java-jni-examples package for more info.
Want to unsubscribe from this list?
Send a message to firstname.lastname@example.org
More information about the Cygwin