| | |
Heap corruption probelm when i try to return std::string from function in dll
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jan 2009
Posts: 16
Reputation:
Solved Threads: 0
Hi all,
I am working on vs2005 (vc++8).
I have created one dll in vs2005(vc++8), in that we have one function which returns "std::string" .
when i load this dll in another vs2005(vc++8) application and call the function which returns "std::string",
we get following error:
Windows has triggered a breakpoint in vstestdll.exe.
This may be due to a corruption of the heap, and indicates a bug in vstestdll.exe or any of the DLLs it has loaded.
The output window may have more diagnostic information
For more detail code is as follows:
I am working on vs2005 (vc++8).
I have created one dll in vs2005(vc++8), in that we have one function which returns "std::string" .
when i load this dll in another vs2005(vc++8) application and call the function which returns "std::string",
we get following error:
Windows has triggered a breakpoint in vstestdll.exe.
This may be due to a corruption of the heap, and indicates a bug in vstestdll.exe or any of the DLLs it has loaded.
The output window may have more diagnostic information
For more detail code is as follows:
C++ Syntax (Toggle Plain Text)
dll function : std::string getDH1(int clo) { return std::string("abcdefghijklmnopqr"); } .exe code: #define TEST2_API __declspec(dllimport); TEST2_API std::string getDH1(int clo); int _tmain(int argc, _TCHAR* argv[]) { string sam =getDH1(1); return 0; }
•
•
Join Date: Dec 2007
Posts: 360
Reputation:
Solved Threads: 69
Re: Heap corruption probelm when i try to return std::string from function in dll
0
#2 Feb 6th, 2009
What happens if you rewrite your dll function:
C++ Syntax (Toggle Plain Text)
void getDH1(int clo, std::string & str);
Last edited by jencas; Feb 6th, 2009 at 6:43 am.
If you are forced to reinvent the wheel at least try to invent a better one!
Please use code tags - Please mark solved threads as solved
Please use code tags - Please mark solved threads as solved
![]() |
Other Threads in the C++ Forum
- Previous Thread: Console GDI
- Next Thread: Per thread singleton
Views: 625 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll encryption error file forms fstream function functions game getline givemetehcodez google graph homeworkhelper iamthwee ifstream input int integer java lazy lib linkedlist linux loop looping loops map math matrix memory microsoft newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort string strings struct studio system template templates test text tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





