This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: std::string across DLL boundaries
- From: "Gerrit P. Haase" <freeweb at nyckelpiga dot de>
- To: Ilia Mirkin <imirkin at MIT dot EDU>
- Cc: cygwin at cygwin dot com
- Date: Fri, 6 Jan 2006 13:09:14 +0100
- Subject: Re: std::string across DLL boundaries
- References: <1136353916.11293.416.camel@localhost>
- Reply-to: "Gerrit P. Haase" <freeweb at nyckelpiga dot de>
Ilia wrote:
> Hi,
> I've run into a problem passing a string ref to a dll:
> testdll.C: (I've tried adding __declspec(dllimport/export) too)
> void f(std::string& a) { a = "asdf"; }
> test.C:
> int main(void) { std::string a; f(a); std::cout << a << std::endl; }
> If I compile it with static linking, the program works as expected. If f
> is in a dll, then I can't get it to work -- different setups either go
> into an infinite loop at a = "asdf", or dump core.
> If, on the other hand, I do std::string a = "qwer", then it will work
> fine -- it seems as though there may be a problem with the allocator in
> libg++, though I may just be supplying the wrong flags to gcc.
> Could someone either confirm that this is a problem, or, preferably,
> provide instructions for getting this to compile "correctly"? (And if
> this is a problem, are there known workarounds, is there a PR open
> somewhere, etc)
Yes, there was already some related discussion and I opened a PR:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24196
> Thanks,
> Ilia
> P.S. This works fine with MinGW, so it's not some huge windows dll
> limitation.
Gerrit
--
=^..^= http://nyckelpiga.de/donate.html
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/