Returning Strings from DLL Functions

前端 未结 7 1161
北恋
北恋 2020-12-16 01:44

For some reason, returning a string from a DLL function crashes my program on runtime with the error Unhandled exception at 0x775dfbae in Cranberry Library Tester.exe:

7条回答
  •  旧巷少年郎
    2020-12-16 02:28

    This occurs because you're allocating memory in one DLL (using std::string's constructor), and freeing it in another DLL. You can't do that because each DLL typically sets up it's own heap.

提交回复
热议问题