简体   繁体   English

我的c ++项目适用于vc ++ 2008,但不适用于vc ++ 2010

[英]My c++ project works in vc++ 2008 but not in vc++ 2010

I have two vc++ dll projects, which will generate two dlls. 我有两个vc ++ dll项目,它们将生成两个dll。 A 一种

vector<vector<string>> 

object will pass from one dll to another dll. 对象将从一个dll传递到另一个dll。 Both of the projects are configured as multithreaded debug dll. 这两个项目都配置为多线程调试DLL。 And both can be compiled succesfully on vc++ 2008 AND vc++ 2010. However, only the dlls generated from vc++ 2008 projects work. 两者都可以在vc ++ 2008和vc ++ 2010上成功编译。但是,只有从vc ++ 2008项目生成的dll才能工作。 The dlls will be used by another dll compiled under MSDEV version 6.0. dll将由在MSDEV 6.0版下编译的另一个dll使用。 So my question is why the 所以我的问题是为什么

vector<vector<string>>

object cannot be passed between the dlls builted by vc++ 2010? 对象无法在vc ++ 2010构建的dll之间传递? Thx:) 谢谢:)

You can not use STL types in DLL interfaces, if you plan to use different compiler versions for the DLL and the code that uses it. 如果计划对DLL使用不同的编译器版本以及使用它的代码,则不能在DLL接口中使用STL类型。

The implementations of vector and string may differ (and they seem to do in your case), and you will get problems like this. 向量和字符串的实现可能不同(在您的情况下它们似乎也是如此),您将遇到这样的问题。

VC++ 2010 uses the new C++11 standard which involves big changes to template containers like vector (using rvalue references and move semantics, for a start). VC ++ 2010使用新的C ++ 11标准,该标准涉及对像vector这样的模板容器进行大的更改(使用rvalue引用和移动语义,一开始)。

If you're sharing libraries like that, generally the safest option is to make plain, boring standard C interface functions to everything. 如果您正在共享这样的库,通常最安全的选择是为所有内容制作简单,无聊的标准C接口函数。 Those work pretty much everywhere, after all. 毕竟,这些工作几乎无处不在。 The internal implementation can then be done in which ever way you see fit. 然后可以以您认为合适的方式完成内部实施。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM