Article View: borland.public.cppbuilder.nativeapi
Article #6957Re: float MyAdd(float A,float B); int MyAdd(int A, int B); both in one DLL
From: Edward Diener
Date: Sat, 05 Jul 2003 17:09
Date: Sat, 05 Jul 2003 17:09
43 lines
3569 bytes
3569 bytes
Rob wrote: > "Edward Diener" <eddielee@tropicsoft.com> wrote in message > news:3f06de1f$1@newsgroups.borland.com... >> Remy Lebeau (TeamB) wrote: >>> "Miem Chan" <miemchan@yahoo.com> wrote in message >>> news:3f06547e@newsgroups.borland.com... >>> >>>> The problem (and my question) is how we can put >>>> both of these MyAdd functions in to a single DLL >>>> and expect to call proper MyAdd function depending >>>> on the parameters passed ? >>> >>> You can't. DLLs don't support function overloading at all. You >>> have to name each function differently. >> >> This just isn't true. Because of name-mangling in C++, you can have >> function overloading in DLLs. Each function with the same base name >> gets a unique name-mangled name because of its different parameter >> list. Name mangling doesn't work only if the programmer wants to use >> extern "C" in order to have the functions in the DLL called from >> other languages or other C++ implementations. Only in this latter >> case is your statement above correct. >> > > While what you say is correct, exporting mangled names from a DLL > basically means that DLL can only be used with code built with one > C++ compiler. For a lot of usage patterns, that defeats the purpose > of having DLLs in the first place, or makes things more complicated > for developers using them. Since this is a BCB NG, I would expect a question about overloaded function names exported from a DLL to be about creating a BCB DLL to be used by other BCB modules. That is normally what BCB programmers do when they create DLLs with BCB. I don't think creating DLLs for a particular compiler implementation is that unusual. It is, of course, done all the time by 3rd party implementors. It doesn't "defeat the purpose of having DLLs in the first place" at all. Creating DLLs that will work with any language or implementation is IMHO a much rarer situation. It totally gives up OOP programming for procedural programming instead. I am aware that the Windows DLLs are such an example, but the vast majority of programming nowadays is OOP programming of one kind or another and this means implementation-defined DLLs.
Technical Details
Message-ID:
<3f0706f3$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3f06547e@newsgroups.borland.com> <3f0681f5$1@newsgroups.borland.com> <3f06de1f$1@newsgroups.borland.com> <3f06e127@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,81e91db7883b82d8 X-Google-Attributes: gid10cc67,public X-Google-Thread: 102541,81e91db7883b82d8 X-Google-Attributes: gid102541,public X-Google-Thread: 10db1e,81e91db7883b82d8 X-Google-Attributes: gid10db1e,public X-Google-ArrivalTime: 2003-07-05 10:39:23 PST From: "Edward Diener" <eddielee@tropicsoft.com> Newsgroups: borland.public.cppbuilder.nativeapi,borland.public.cppbuilder.oodesign,borland.public.cppbuilder.students References: <3f06547e@newsgroups.borland.com> <3f0681f5$1@newsgroups.borland.com> <3f06de1f$1@newsgroups.borland.com> <3f06e127@newsgroups.borland.com> Subject: Re: float MyAdd(float A,float B); int MyAdd(int A, int B); both in one DLL Date: Sat, 5 Jul 2003 13:09:44 -0400 Lines: 45 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 66.245.8.210 Message-ID: <3f0706f3$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1057425139 66.245.8.210 (5 Jul 2003 10:12:19 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail