delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/03/17/12:11:50

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
X-Authentication-Warning: modi.xraylith.wisc.edu: khan owned process doing -bs
Date: Wed, 17 Mar 1999 11:06:14 -0600 (CST)
From: Mumit Khan <khan AT xraylith DOT wisc DOT edu>
To: "Billinghurst, David (RTD)" <David DOT Billinghurst AT riotinto DOT com DOT au>
cc: cygwin AT sourceware DOT cygnus DOT com
Subject: Excel-callable DLL [RE: CFORTRAN for cygwin/egcs?]
In-Reply-To: <A9E96A79C068D211A6A90000C07BDF0D1DE699@CRTSMAIL>
Message-ID: <Pine.SUN.3.93.990317110032.5822F-100000@modi.xraylith.wisc.edu>
MIME-Version: 1.0

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
essential info:

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 AT 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.

Regards,
mumit



--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019