Article View: borland.public.cppbuilder.nativeapi
Article #1231Re: Using __stdcall
From: Sue King
Date: Mon, 15 Oct 2007 04:35
Date: Mon, 15 Oct 2007 04:35
85 lines
3732 bytes
3732 bytes
Bob Gonder wrote:
> Sue King wrote:
>
>> I have some old C code that I wish to compile using the 2007 C/C++ in
>> RAD Studio Professional. This links to a dll that uses __stdcall and
>> gives names such as _Function@4 in the .lib file.
>
Hi Bob,
Thanks for replying.
I've read the posts and think I almost understand what is happening/not
happening. (Pity I put __ in my google search for stdcall/cdecl)
> Matching Google links:
> http://groups.google.com/group/borland.public.cppbuilder.winapi/browse_thread/thread/3f81609418611afd
> http://tinyurl.com/37zs7z
>
> http://groups.google.com/group/borland.public.cpp.borlandcpp/browse_thread/thread/87925e78fe34c6c5
> http://tinyurl.com/2n3jbn
>
>> I don't seem to be able to get the compiler to pick up the mangled name.
>> The error is [ILINK32 Error]Error: Unresolved external 'Function'
>> referenced from xx.obj
>
> What does the function delcaration look like?
> It should look something like this
>
> #define MYDLLAPI __declspec(dllimport)
> #ifdef __cplusplus
> extern "C" {
> #endif
> MYDLLAPI BOOL __stdcall Function( /*ParamList*/ );
> #ifdef __cplusplus
> }
> #endif
Yes it does.
#ifdef __cplusplus
extern "C"{
#endif
__declspec(dllimport) mystruct * __stdcall Function(void);
#ifdef __cplusplus
}
#endif
Previously I didn't have the #ifdef cplusplus as I am not using any c++
but I've added it in anyway.
>
> Another thing, in Borland, __stdcall removes the leading _ that
> C normally places in front of function names. So you might try
> using _Function() in your application.
I tried this but no joy. Same error _Function unresolved.
>
> Or fixup a .DEF file as Ed suggests in the above lnks.
I've tried this but am missing something.
What I did was create a .def file using impdef. The file has entries
such as
Function = _Function@0
So then I included it in my project, but it made no difference.
The second reference refers to a lib command to create the .lib file
from the .def.
What is this for Borland ? I tried 'lib' but this picked up a lib
command for another compiler I have installed, and the creation of a
.lib from the .def is invalid for this command. Or if it is the correct
command, where does it live ? I looked in CodeGear ... \bin and could
not find an exe that seemed appropriate. Ihave one in a VStudio 8
directory but as I don't have Vstudio 8 installed it won't run. (Think
these are there because of MSDN stuff).
It looks like Jeff ended up using cdecl instead of stdcall.
>
>> (Or the correct newsgroup if this is not the right one)
>
> The .IDE group would be ideal for settings.
>
Thanks
Sue
Technical Details
Message-ID:
<4712eddf@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!eweka.nl!lightspeed.eweka.nl!194.134.4.77.MISMATCH!news2.euro.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<47129b93$1@newsgroups.borland.com> <p695h3tbk1cc4q0o89v2nqj1u41e68hlct@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,4be438fa70c4738f X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Date: Mon, 15 Oct 2007 14:35:56 +1000 From: Sue King <sue@torrensbs.com.au> User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Using __stdcall References: <47129b93$1@newsgroups.borland.com> <p695h3tbk1cc4q0o89v2nqj1u41e68hlct@4ax.com> In-Reply-To: <p695h3tbk1cc4q0o89v2nqj1u41e68hlct@4ax.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 203.34.140.74 Message-ID: <4712eddf@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1192422879 203.34.140.74 (14 Oct 2007 21:34:39 -0700) Lines: 86 Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!eweka.nl!lightspeed.eweka.nl!194.134.4.77.MISMATCH!news2.euro.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail