X-Spam-Check-By: sourceware.org Subject: std::string across DLL boundaries From: Ilia Mirkin To: cygwin AT cygwin DOT com Content-Type: text/plain Date: Wed, 04 Jan 2006 00:51:56 -0500 Message-Id: <1136353916.11293.416.camel@localhost> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Score: 1.217 Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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) Thanks, Ilia P.S. This works fine with MinGW, so it's not some huge windows dll limitation. -- 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/