CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2011
    Posts
    51

    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.

  2. #2
    Join Date
    Apr 2011
    Posts
    51

    Re: what is std::container_base12 and std::container_base0

    problem has been solved. It is due to release/debug difference. Thanks.

  3. #3
    Join Date
    Oct 2008
    Posts
    1,456

    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 ... ).

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: what is std::container_base12 and std::container_base0

    Quote Originally Posted by superbonzo View Post
    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
  •  





Click Here to Expand Forum to Full Width

Featured