--- Massimiliano Mirra <[EMAIL PROTECTED]> wrote: > Danny Smith <[EMAIL PROTECTED]> 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 [EMAIL PROTECTED] 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/