Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <20030402011336.8866.qmail@web21401.mail.yahoo.com> Date: Wed, 2 Apr 2003 11:13:36 +1000 (EST) From: =?iso-8859-1?q?Danny=20Smith?= Subject: Re: Can open() from console app, not from dll To: Massimiliano Mirra Cc: cygwin AT cygwin DOT com In-Reply-To: <87d6k5n57f.fsf@prism.localnet> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit --- Massimiliano Mirra wrote: > Danny Smith 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 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 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/