简体   繁体   English

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

[英]Error compiling in release mode but not in debug mode

When I compile on VS 2008 in deubg mode everything works fine. 当我以deubg模式在VS 2008上编译时,一切正常。 When I compile the same thing in release mode not everything works. 当我在发布模式下编译相同的东西时,并非一切正常。 As far as I can tell the include directories are the same and there are no additional preprocessor symbols. 据我所知,include目录是相同的,并且没有其他预处理器符号。

Any help? 有帮助吗?

1>zlib.cpp 1>C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\include\\xutility(419) : error C2664: 'CryptoPP::AllocatorWithCleanup::AllocatorWithCleanup(const CryptoPP::AllocatorWithCleanup &)' : cannot convert parameter 1 from 'CryptoPP::AllocatorWithCleanup' to 'const CryptoPP::AllocatorWithCleanup &' 1> with 1> [ 1> 1> zlib.cpp 1> C:\\ Program Files(x86)\\ Microsoft Visual Studio 9.0 \\ VC \\ include \\ xutility(419):错误C2664:'CryptoPP :: AllocatorWithCleanup :: AllocatorWithCleanup(const CryptoPP :: AllocatorWithCleanup&)' :无法将参数1从'CryptoPP :: AllocatorWithCleanup'转换为'const CryptoPP :: AllocatorWithCleanup&'1>,其中1> [1>
T=std::_Aux_cont 1> ] 1> T = std :: __ Aux_cont 1>] 1>
and 1> [ 1> 和1> [1>
T=CryptoPP::HuffmanDecoder::CodeInfo 1> ] 1> and 1> [ 1> T=std::_Aux_cont 1> T = CryptoPP :: HuffmanDecoder :: CodeInfo 1>] 1>和1> [1> T = std :: _ Aux_cont 1>
] 1> Reason: cannot convert from 'CryptoPP::AllocatorWithCleanup' to 'const CryptoPP::AllocatorWithCleanup' 1> with 1> [ 1> ] 1>原因:无法从“ CryptoPP :: AllocatorWithCleanup”转换为“ const CryptoPP :: AllocatorWithCleanup” 1>并带有1> [1>
T=CryptoPP::HuffmanDecoder::CodeInfo 1> ] 1> and 1> [ 1> T=std::_Aux_cont 1> T = CryptoPP :: HuffmanDecoder :: CodeInfo 1>] 1>和1> [1> T = std :: _ Aux_cont 1>
] 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 1> C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\include\\xutility(417) : while compiling class template member function 'std::_Container_base_aux_alloc_real<_Alloc>::_Container_base_aux_alloc_real(_Alloc)' 1> with 1> [ 1> ] 1>没有可用的用户定义转换运算符可以执行此转换,否则无法调用该运算符1> C:\\ Program Files(x86)\\ Microsoft Visual Studio 9.0 \\ VC \\ include \\ 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)\\Microsoft Visual Studio 9.0\\VC\\include\\vector(421) : see reference to class template instantiation 'std::_Container_base_aux_alloc_real<_Alloc>' being compiled 1> with 1> _Alloc = CryptoPP :: AllocatorWithCleanup 1>] 1> C:\\ Program Files(x86)\\ Microsoft Visual Studio 9.0 \\ VC \\ include \\ vector(421):请参见对类模板实例化“ std :: _ Container_base_aux_alloc_real <_Alloc>”的引用用1>编译1>
[ 1> [1>
_Alloc=CryptoPP::AllocatorWithCleanup 1> ] 1> C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\include\\vector(439) : see reference to class template instantiation 'std::_Vector_val<_Ty,_Alloc>' being compiled 1> with 1> [ 1> _Ty=CryptoPP::HuffmanDecoder::CodeInfo, 1> _Alloc = CryptoPP :: AllocatorWithCleanup 1>] 1> C:\\ Program Files(x86)\\ Microsoft Visual Studio 9.0 \\ VC \\ include \\ vector(439):请参见对类模板实例化'std :: _ Vector_val <_Ty,_Alloc>的引用'正在被编译1>与1> [1> _Ty = CryptoPP :: HuffmanDecoder :: CodeInfo,1>
_Alloc=CryptoPP::AllocatorWithCleanup 1> ] 1> _Alloc = CryptoPP :: AllocatorWithCleanup 1>] 1>
C:\\myproject\\sshlib\\zinflate.h(79) : see reference to class template instantiation 'std::vector<_Ty,_Ax>' being compiled 1> with 1> C:\\ myproject \\ sshlib \\ zinflate.h(79):请参见对类模板实例化'std :: vector <_Ty,_Ax>'的引用,正在使用1>和1>进行编译
[ 1> [1>
_Ty=CryptoPP::HuffmanDecoder::CodeInfo, 1> _Ty = CryptoPP :: HuffmanDecoder :: CodeInfo,1>
_Ax=CryptoPP::AllocatorWithCleanup 1> ] 1>zinflate.cpp _Ax = CryptoPP :: AllocatorWithCleanup 1>] 1> zinflate.cpp

The line of code it eventually points to is: 它最终指向的代码行是:

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

Edit: More info: 编辑:更多信息:

I get this error exactly when my preprocessor contains NDEBUG instead of _DEBUG. 当我的预处理器包含NDEBUG而不是_DEBUG时,我得到此错误。 If I change my release config to have _DEBUG isntead it compiles. 如果我将发布配置更改为_DEBUG istead,则会进行编译。 Why? 为什么?

It's a bug in the Visual C++ compiler. 这是Visual C ++编译器中的错误。 See http://old.nabble.com/-jira--Created:-%28QPID-1458%29-C%2B%2B-common-compile-error-in-VC9-Release-mode-td20469700.html . 请参阅http://old.nabble.com/-jira--创建:-%28QPID-1458%29-C%2B%2B-common-compile-error-in-VC9-Release-mode-td20469700.html

You can work around it by disabling checked iterators : 您可以通过禁用选中的迭代器来解决此问题:

#define _SECURE_SCL 0

But be warned: if you link against a third-party library that was compiled with _SECURE_SCL enabled, like eg boost , memory corruption can (and will) occur. 但请注意:如果链接_SECURE_SCL启用_SECURE_SCL编译的第三方库,例如boost ,则可能(并且将)发生内存损坏。

Coming back to C++ after many years, I encountered a similar error. 多年后回到C ++,我遇到了类似的错误。 Turned out it had nothing to do with this bug and everything to do with the fact that I hadn't updated my Release configuration to the same settings as used in the Debug configuration! 事实证明,它与该错误无关,并且与我没有将Release配置更新为与Debug配置中使用的相同设置有关! So for the other noobs out there -- remember to make sure that you have the same Character Sets, CLR Support, Include Directories, Additional Dependencies, and so forth in all your configurations. 因此,对于那里的其他菜鸟,请记住在所有配置中确保您具有相同的字符集,CLR支持,包含目录,其他依赖关系,等等。

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

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