🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #10651

Re: DLL and std::string?

#10651
From: Remy Lebeau (TeamB)
Date: Wed, 07 Apr 2004 00:29
36 lines
2332 bytes
"nicolasr" <nicolasrNOSPAMATSIGNgmx.net> wrote in message
news:40733f34@newsgroups.borland.com...

> 1) I would like to use the std::string class for parameters
> of the exported functions. Are there any issues I should
> be aware of with this?

That depends on what environments you want to use your DLL from exactly.  In
general, though, I would suggest avoiding using classes of any kind as the
function parameters.  They will usually not be very portable.  You can use
them inside the DLL as much as you want, though.

> The DLL will only be used from C++ code, most likely only from BCB.

Well, it makes a big difference whether it will be used ONLY by BCB, or just
MOSTLY by BCB.  As soon as you introduce more environments, you increase the
number of compatibility issues that you have to deal with.

> 3) Below is my DLL code. The client code loads the DLL
> dynamically and calls the Validate function. The Validate
> function accepts the name of an internal function to call
> and a std::string parameter specifying a file name that it
> passes on to the internal function.

I would suggest you use raw char* pointers whenever you use strings for
exported function parameters.  Those are the most compatible types of
strings across environments.

> After the line "ifstream in..." the "fileName" content is ???? like
> something corrupts the stack?

Very possibly.


Gambit
Technical Details
Message-ID: <40734b69$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsrout1.ntli.net!news.ntli.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40733f34@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,fd71d18cb19fccaf
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-04-06 17:39:53 PST
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <40733f34@newsgroups.borland.com>
Subject: Re: DLL and std::string?
Date: Tue, 6 Apr 2004 17:29:37 -0700
Lines: 38
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: 67.22.138.253
Message-ID: <40734b69$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1081297769 67.22.138.253 (6 Apr 2004 17:29:29 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsrout1.ntli.net!news.ntli.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail