
passing std::vector to a DLL by reference
The context was with respect to having one shared heap (so that exporting a
vector from a DLL will work.)
The real problem is allocating memory in a DLL and deallocating it in the
EXE (or another DLL). There is never a guarantee that they are all using
the same heap (but you can work very hard to try to make sure they are.)
My opinion is that one should AVOID this kind of behavior AS MUCH AS
POSSIBLE. (i.e. never do it.)
However, given that people do do this, I try to warn that you can't mix a
debug EXE with a release DLL (or whatever) because they'll (again) be using
different heaps (and different heap deallocation strategies.)
YMMV
By the way, if you want to be real fancy (so as to have your cake and eat it
to) write your own allocator class to work with the vector which uses a safe
mechanism for allocation and deallocation like VirtualAlloc, LocalAlloc,
GlobalAlloc, or CoTaskMemAlloc.
(and if someone does write this, share it with the world so we can all stop
living in this nightmare. ;-)
--
Reginald Blue | Opinions expressed here do not
Natural Language Understanding | necessarily represent those of
Unisys Corporation | my employer.
--------------------------------+-------------------------------
NL technology,speech application| My email address is wrong, you
development training, see: | need to remove the obvious.
http://www.speechdepot.com/ +-------------------------------
Quote:
> > However, note that you will NEVER be able to mix Debug and Release
builds.
> > They must both be either Debug or Release.
> I am not clear about the context of the above statement.
> I have mixed debug & release libraries many a times for debugging
> purposes.
> I did not have any problems.