DLL help needed...

Richard Stanton stanton@haas.berkeley.edu
Mon Dec 22 13:23:00 GMT 1997


I'm getting close to creating working DLLs. With a lot of help from
Giandomenico De Sanctis, I've actually created a DLL file that
passes/returns short ints, and can be used in Excel 97, but I'm having
trouble when the functions pass/return double arguments. In fact, I'm
having trouble even in plain C.

Here's a simple example, which produces the following (odd looking)
output

[c:\projects\excel]exe
i 10.000000, j 11.000000, k -1.#IND00

When I pass everything as short instead of double, it all seems to
work OK. Any idea what I'm doing wrong? I attach all the necessary
files to get this to compile.

By the way, I'm compiling this using mingw32.

Thanks a lot.

Richard Stanton

------------------------------------------------------------------------

exe.c:

------------------------------------------------------------------------

#include <stdio.h>

double RHS (double x, double y) __attribute__((stdcall));

int main()
{
	double i, j, k;

	i = 10;
        j = 11;

	k = RHS(i,j);

	printf ("i %lf, j %lf, k %lf\n", i, j, k);
    
	return 0;
}

------------------------------------------------------------------------

dll.c:

------------------------------------------------------------------------

double RHS (double x, double y)
{
    return (x + y);
}

------------------------------------------------------------------------

dll.def:

------------------------------------------------------------------------

EXPORTS
RHS
RHS@16=RHS

------------------------------------------------------------------------

makefile:

------------------------------------------------------------------------

dll.dll:	dll.c dll.def
	dlltool --def dll.def --output-exp dll.exp --output-lib dll.a --dllname dll.dll -k
	gcc -g -o dll.dll dll.c dll.exp -Xlinker --image-base=0x40000000 -dll -mrtd -ggdb3

exe.exe:	exe.c dll.dll
	gcc exe.c dll.a -g -o exe.exe

------------------------------------------------------------------------

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".



More information about the Cygwin mailing list