🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: DLL and std::string?

#10668
From: nicolasr
Date: Wed, 07 Apr 2004 17:17
44 lines
2340 bytes
thanks for the code. I switched everything to using char*
and added the missing __stdcall declaraction.
The ifstream stack corruption remains, though. I also
searched Google and it seems other people had similar problems.

I replaced std::ifstream with TFileStream and now it works!

Nick

> 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: <40743797@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsrout1.ntli.net!news.ntli.net!colt.net!diablo.netcom.net.uk!netcom.net.uk!newsfeed.icl.net!proxad.net!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <40733f34@newsgroups.borland.com> <40734b69$1@newsgroups.borland.com> <407356a8$1@newsgroups.borland.com> <407357f0@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-07 10:26:07 PST
From: "nicolasr" <nicolasrNOSPAMATSIGNgmx.net>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <40733f34@newsgroups.borland.com> <40734b69$1@newsgroups.borland.com> <407356a8$1@newsgroups.borland.com> <407357f0@newsgroups.borland.com>
Subject: Re: DLL and std::string?
Date: Wed, 7 Apr 2004 19:17:05 +0200
Lines: 46
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: 80.133.160.248
Message-ID: <40743797@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1081358231 80.133.160.248 (7 Apr 2004 10:17:11 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsrout1.ntli.net!news.ntli.net!colt.net!diablo.netcom.net.uk!netcom.net.uk!newsfeed.icl.net!proxad.net!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail