Subject: Re: Can open() from console app, not from dll
From: Danny Smith <[email-masked]>
To: Massimiliano Mirra <[email-masked]>
Cc: [email-masked]
Date: Wed, 2 Apr 2003 11:13:36 +1000 (EST)

--- Massimiliano Mirra <[email-masked]> wrote: > Danny Smith
<[email-masked]> writes:
> 
> >> I am able to open a file and write into it from a console application,
> >> but the same fails when done from within a function that is stored in
> >> a DLL and called from a Visual Basic application.
> >
> > VB expects stdcall convention.
> > Try adding WINAPI to OpenSomething
> 
> Hmmm.  If I understand correctly, and it's to be written ``int WINAPI
> OpenSomething'', it seems that it becomes unable to even call the
> function:
> 
> ``Can't find DLL entry point OpenSomething in foo.dll''

In this specific case, the __stdcall isn't really necessary, since your are
passing parameters.  In general however, VB expects the callee to cleanup the
stack.

I added the __stdcall qualifier OpenSomething and built dll
like so:
gcc --shared -ofoo.dll -Wl,--add-stdcall-alias foo.c

This will export OpenSomething@0 as well as the alias OpenSomething

I put the dll where Excel could find it
and added this to a module in a worksheet:
Declare Function OpenSomething Lib "foo.dll" () As Integer

and when I called OpenSomething from the worksheet it opened the file and wrote
to it. No problem

Ditto if I build with -mno-cygwin.

However, if your VB app is calling MS runtime IO functions to do other things 
you may  have cygwin1.dll vs MS runtime conflicts.

Have you tried with -mno-cygwin?

Danny

http://mobile.yahoo.com.au - Yahoo! Mobile
- Check & compose your email via SMS on your Telstra or Vodafone mobile.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/