🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.oodesign
Article #59

Re: Class in a DLL

#59
From: Andrue Cope [TeamB]
Date: Fri, 06 May 2005 11:00
35 lines
2130 bytes
Colin B Maharaj wrote:

> Now, is there some way that I can then call this code , which I want
> to put in a DLL and instantiate multiple instances of the classes in
> the DLL.

Yes but importing/exporting object instances is proprietary and
language specific. You will not find it easy to import a Borland object
from a VC application. Should you or someone else ever need to use
those classes from a different language it will probably be nigh-on
impossible.

Generally accepted wisdom is to provide handle based access to classes
across DLL boundaries. The handle can either be a subscript into an
array of objects or the pointer to the object instance casted to 'void
*'.

Example 1:Easier to spot invalid handles.
// DLL code
int DLL_Exported_Wibbler( int objectHandle )
{
  return MyObjectList[ objectHandle ]->Wibble();
}

Example 2:Slightly faster than using an array/vector
// DLL code
int DLL_Exported_Wibbler( void * objectHandle )
{
  return reinterpret_cast<TMyObject *>( objectHandle )->Wibble();
}

-- 
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html
Technical Details
Message-ID: <427b4e5d@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <427b38fd$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10db1e,4508b613cdd64647
X-Google-Attributes: gid10db1e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Andrue Cope [TeamB]" <no.spam@not.a.valid.address>
Subject: Re: Class in a DLL
Newsgroups: borland.public.cppbuilder.oodesign
References: <427b38fd$1@newsgroups.borland.com>
User-Agent: XanaNews/1.17.4.1
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
NNTP-Posting-Host: 217.207.223.34
Message-ID: <427b4e5d@newsgroups.borland.com>
Date: 6 May 2005 04:00:45 -0700
X-Trace: newsgroups.borland.com 1115377245 217.207.223.34 (6 May 2005 04:00:45 -0700)
Lines: 35
X-Authenticated-User: acope
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail