This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Can open() from console app, not from dll

 --- Massimiliano Mirra <mmirra at libero dot it> wrote: > Danny Smith
<danny_r_smith_2001 at yahoo dot co dot nz> 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

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 at 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 - Yahoo! Mobile
- Check & compose your email via SMS on your Telstra or Vodafone mobile.

Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]