Article View: borland.public.cppbuilder.nativeapi
Article #10653Re: DLL and std::string?
From: Remy Lebeau (TeamB)
Date: Wed, 07 Apr 2004 01:23
Date: Wed, 07 Apr 2004 01:23
41 lines
2110 bytes
2110 bytes
"nicolasr" <nicolasrNOSPAMATSIGNgmx.net> wrote in message
news:407356a8$1@newsgroups.borland.com...
> However I don't understand why using std::ifstream
> inside the DLL always gets me an AV
> (read of address 00000000). Any idea?
It is not related to the std::ifstream itself, but more likely to the
std::string that you passed to it. Once you change to char* instead, you
shouldn't have the problem anymore. For example:
bool FileType1Test(const char *fileName)
{
ifstream in(fileName);
char c;
in >> c;
return ( c == 'A' );
}
extern "C" __declspec(dllexport) char* __stdcall Validate(const char*
funcName, const char* args)
{
if( std::string(funcName) == "FileType1Test" )
return FileType1Test(args) ? "TRUE" : "FALSE";
else
return "FALSE";
}
> typedef void (*PTestFunc)(const char* fileName);
You left out the __stdcall convention, thus you are going to corrupt the
stack. It needs to be this instead:
typedef void (__stdcall *PTestFunc)(const char* fileName);
Gambit
Technical Details
Message-ID:
<407357f0@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40733f34@newsgroups.borland.com> <40734b69$1@newsgroups.borland.com> <407356a8$1@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 18:39:51 PST From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <40733f34@newsgroups.borland.com> <40734b69$1@newsgroups.borland.com> <407356a8$1@newsgroups.borland.com> Subject: Re: DLL and std::string? Date: Tue, 6 Apr 2004 18:23:04 -0700 Lines: 43 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: <407357f0@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1081300976 67.22.138.253 (6 Apr 2004 18:22:56 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail