-
February 24th, 2015, 03:12 PM
#1
what is std::container_base12 and std::container_base0
Hi, folks,
I am trying to pass a std::string from one dll to another by boost::any. It is odd that the first 4 letters are always lost during this process, i.e. the buffer pointer is shifted by 4 bytes. When I looked into the code, it turned out that in one dll, std::container_base0 is used while in native C++ std::container_base12 is used instead. I suspect that is what caused the problem. Does anyone know how to tell the compilers to use the same container?
Thanks a lot,
CR
Last edited by caperover2000; February 24th, 2015 at 04:25 PM.
-
February 24th, 2015, 05:10 PM
#2
Re: what is std::container_base12 and std::container_base0
problem has been solved. It is due to release/debug difference. Thanks.
-
February 25th, 2015, 03:29 AM
#3
Re: what is std::container_base12 and std::container_base0
no, it has not been solved; the c++ standard library does not define an ABI so passing std::string ( or any other container ) across DLL boundaries is dangerous at best; any change in the compiler settings or version or even in your own source code ( templates instantiations usually occurs on a per translation unit basis ) could change the resulting binary layout of your classes, resulting in undefined behavior when accessed from both sides. So, either avoid STL containers in favor of c-buffers or some abstract interface, or use some binary object model ( COM and the like ), or employ some form of safe transport of your c++ types ( boost serialization, google protocol buffers, etc ... ).
-
February 25th, 2015, 04:47 AM
#4
Re: what is std::container_base12 and std::container_base0
Originally Posted by superbonzo
or employ some form of safe transport of your c++ types ( boost serialization, google protocol buffers, etc ... ).
... Win32 API guaranteed compatible types like plain C-string (LPCTSTR), or BSTR ...
Best regards,
Igor
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|