From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, T_FILL_THIS_FORM_SHORT autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,8141f2ef049fcd7e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-11 06:39:29 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Help with GNAT, WinNT, StdCall, dll, exported names Date: 11 Oct 2001 09:28:22 -0400 Organization: NASA Goddard Space Flight Center Message-ID: References: <%lfx7.6$_o6.503@newsc.telia.net> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: skates.gsfc.nasa.gov 1002807013 24072 128.183.220.71 (11 Oct 2001 13:30:13 GMT) X-Complaints-To: dscoggin@cne-odin.gsfc.nasa.gov NNTP-Posting-Date: 11 Oct 2001 13:30:13 GMT User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 Xref: archiver1.google.com comp.lang.ada:14256 Date: 2001-10-11T13:30:13+00:00 List-Id: "Peter Hend�n" writes: > I'm using gnat 3.13p, trying to build a dll that exports functions > that are to be called by a windows service. The problem is > that the functions are declared in the .h file as > > BOOL WINAPI Foobar(LPFUNNY_STRUCT fum); > > Now I have defined an Ada function for this, and > it works fine when I export it as > pragma Export(C, Foobar, "Foobar");. > > Of course this will be called exactly once, because > it is the wrong calling convention, and after its return > the stack is fubar. > > When I try to declare it StdCall instead of C, I am > not able to link it. Whatever I put in the .DEF file > it comes out wrong. I get from the last gnatlink step > in gnatdll: > > mydll.exp(.edata+0x34):fake: undefined reference to `Foobar' > > I have tried everything in the gnat user's guide, searched > this groups archive and generally banged my head against > the wall in appropriate - and perhaps not so appropriate - > ways. Please help! You don't mention what C compiler you are using. I have found that different C compilers (and different Ada compilers) have different naming conventions, usually having to do with prepending and underscore. Here's my matrix: compiler calling function link DLL convention name name name Borland C++ Cdecl foo _foo _foo stdcall foo foo foo Borland C Cdecl foo _foo _foo stdcall foo foo foo GNAT Ada C foo _foo foo (stdcall not supported in DLLs) Gnu C C foo _foo foo ObjectAda Ada DLL_Cdecl foo _foo foo DLL_Stdcall foo _foo foo I also have this note: Since GNAT Ada does not support the stdcall convention for DLLs, we use the Cdecl convention everywhere. That was true for 3.12, apparently it's not true anymore. Hope this helps! -- -- Stephe