Article View: borland.public.cppbuilder.nativeapi
Article #11232Re: Run Time Dynamic linking
From: Alan Bellingham
Date: Fri, 20 Feb 2004 16:11
Date: Fri, 20 Feb 2004 16:11
38 lines
2450 bytes
2450 bytes
"Ed Mulroy [TeamB]" <dont_email_me@bitbuc.ket> wrote:
>Casting an lvalue may be uncommon but I do not think it is a non-standard
>extension. Except for the case of GetProcAddress I think it is usually
>uglier and more difficult to understand than other ways of doing things so
>is best avoided.
To quote a footnote from the current C standard:
85) A cast does not yield an lvalue.
And since assignment requires an lvalue as its target, this rather
implies that the cast-on-the-left method isn't actually legal.
>I think there must have been some other reason that you had to change your
>GetProcAdddress calls when using VC. Casting to FARPROC on the left is not
>uncommon in MS code. If I remember correctly, I first saw it in use in OS/2
>code when using an MS compiler.
I suspect that it's a bug in early compilers that got left in because
it's too useful for such code.
I actually use a template:
template<typename FuncType> vool
WireupFunction(HINSTANCE Inst, FuncType& FnPtr, char const* FnName)
{
FnPtr = reinterpret_cast<FuncType>(GetProcAddress(Inst, FnName));
return (FnPtr != 0);
}
WireupFunction(m_Inst, ClearPrintString, "ClearPrintString");
Once the template exists, it's actually less typing.
Alan Bellingham
--
ACCU Conference 2004 - http://https://www.accu.org/conference/
Technical Details
Message-ID:
<glbc305oe8fpeo2u3mnf0s8eajufdmtbrh@4ax.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<4034d732$1@newsgroups.borland.com> <4034e538$1@newsgroups.borland.com> <4034e949$1@newsgroups.borland.com> <40350424$1@newsgroups.borland.com> <p8al49eo5xi$.1rbxmasbh351g.dlg@40tude.net> <40361a16$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,c9838237a73aa85e X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-02-20 08:15:01 PST From: Alan Bellingham <alanb@episys.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Run Time Dynamic linking Date: Fri, 20 Feb 2004 16:11:02 +0000 Reply-To: alanb@episys.com Message-ID: <glbc305oe8fpeo2u3mnf0s8eajufdmtbrh@4ax.com> References: <4034d732$1@newsgroups.borland.com> <4034e538$1@newsgroups.borland.com> <4034e949$1@newsgroups.borland.com> <40350424$1@newsgroups.borland.com> <p8al49eo5xi$.1rbxmasbh351g.dlg@40tude.net> <40361a16$1@newsgroups.borland.com> X-Newsreader: Forte Agent 2.0/32.640 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 193.129.251.130 X-Trace: newsgroups.borland.com 1077293461 193.129.251.130 (20 Feb 2004 08:11:01 -0800) Lines: 38 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail