在发布模式下编译时出错但在调试模式下不能编译

问题描述:

当我在VS 2008上以deubg模式编译时,一切正常。 当我在发布模式下编译相同的东西时,并非一切正常。据我所知,包含目录是相同的,没有额外的预处理器符号。在发布模式下编译时出错但在调试模式下不能编译

任何帮助?

1> zlib.cpp 1> C:\ Program Files文件 (x86)的\微软的Visual Studio 9.0 \ VC \ \包括xutility(419):错误C2664: “CryptoPP :: AllocatorWithCleanup :: AllocatorWithCleanup (常量 CryptoPP :: AllocatorWithCleanup &)” :能参数1不转换从 'CryptoPP :: AllocatorWithCleanup' 至 'const的 CryptoPP :: AllocatorWithCleanup &' 1> 1> [1>
T = STD: :_Aux_cont 1>] 1>
和1> 1>
T = CryptoPP :: HuffmanDecoder :: CodeInfo 1> 1> 1> [ 1> T =标准:: _ Aux_cont 1>
] 1>原因:不能转换 从 'CryptoPP :: AllocatorWithCleanup' 至 'const的 CryptoPP :: AllocatorWithCleanup' 1> 其中1> [1>
T = CryptoPP :: HuffmanDecoder :: CodeInfo 1> 1> 1> [ 1> T = std :: _ Aux_cont 1>
] 1>没有用户定义的转换 运算符可用,可以执行 这个转换,或者o操作结束时切 不能称之为1> C:\ PROGRAM 文件(x86)\微软的Visual Studio 9.0 \ VC \包括\ xutility(417):在编译类模板成员 功能 “的std :: _ Container_base_aux_alloc_real < _Alloc> :: _Container_base_aux_alloc_real(_Alloc)” 1> 1> [1>
_Alloc = CryptoPP :: AllocatorWithCleanup 1> 1> C:\ Program Files文件 (x86)的\微软的Visual Studio 9.0 \ VC \包括\矢量( 421):请参阅参考类模板 实例化 'std :: _ Container_base_aux_alloc_real < _Alloc>' 正在编译1> 1>
[1>
_Alloc = CryptoPP :: AllocatorWithCleanup 1> 1> C:\ Program Files文件 (x86)的\微软的Visual Studio 9.0 \ VC \包括\矢量(439):见参考类模板 实例 '的std :: _ Vector_val < _Ty,_Alloc>' 被 编译1> 1> [1> _Ty = CryptoPP :: HuffmanDecoder :: CodeInfo, 1>
_Alloc = CryptoPP :: AllocatorWithCleanup 1>] 1>
C:\ myproject \ sshlib \ zinflate。H(79): 见参考类模板 实例化 '的std ::矢量< _Ty,_AX>' 正在编译1> 1>
[1>
_Ty = CryptoPP :: HuffmanDecoder :: CodeInfo, 1>
_AX = CryptoPP :: AllocatorWithCleanup 1> 1> zinflate.cpp

的代码行它最终点是:

std::vector<CodeInfo, AllocatorWithCleanup<CodeInfo> > m_codeToValue; 

编辑:更多信息:

当我的预处理器包含NDEBUG而不是_DEBUG时,我得到这个错误。如果我更改我的发行版配置以使_DEBUG处于非编译状态。为什么?

+0

看起来像一个常量问题,在你的向量上有allocator参数。你有更多的代码? – 2010-10-07 19:04:02

+0

#defining'_DEBUG'基本上将构建切换到调试模式。 Microsoft STL的自定义分配器策略在调试模式下不同,并且不受该错误的影响。请参阅下面我的答案中的Nabble链接。 – 2010-10-07 19:21:29

这是Visual C++编译器中的一个错误。见http://old.nabble.com/-jira--Created:-%28QPID-1458%29-C%2B%2B-common-compile-error-in-VC9-Release-mode-td20469700.html

你可以解决它通过禁用checked iterators

#define _SECURE_SCL 0 

但要注意:如果你对一个已编译与_SECURE_SCL启用,像例如第三方库链接内存损坏可能(并且将会)发生。

+0

我很确定我曾经有过这个错误,并且它在安装了Visual Studio Service Pack后就消失了,也许吧?我们的工作与提升。 – 2010-10-07 19:19:23

+0

有趣。 @MS SQL Server,你能提供你的编译器的确切版本吗? – 2010-10-07 19:25:25

+0

这是基于VS2008的安装。我希望这是解决方案。我首先尝试通过applygin 2008 SP1来查看是否可行。安装完成后,我会更新票证。 – 2010-10-07 19:26:35

多年后回到C++,我遇到了类似的错误。原来,这与这个bug无关,与我没有将Release配置更新为Debug配置中使用的相同设置有关。因此,对于其他noobs - 请记住确保在所有配置中具有相同的字符集,CLR支持,包含目录,附加依赖关系等。