Passing reference to STL vector over dll boundary

前端 未结 7 1863
一个人的身影
一个人的身影 2020-12-01 08:02

I have a nice library for managing files that needs to return specific lists of strings. Since the only code I\'m ever going to use it with is going to be C++ (and Java but

相关标签:
7条回答
  • 2020-12-01 09:01

    The memory is allocated in the executable and passed as a reference to the dll function, values are added via the reference, and then those are processed and finally deallocated back in the executable.

    Adding values if there is no space left (capacity) means a reallocation, so the old will be deallocated & a new will be allocated. That'll be done by the library's std::vector::push_back function, which will use the library's memory allocator.

    Other than that, you've got the obvious compile-settings-must-match-exactly and of course they are kind of compiler-specifics dependant. You've most likely got to keep them synced in terms of compiles.

    0 讨论(0)
提交回复
热议问题