在发布模式下编译出错,但在调试模式下编译不会出错
当我在 VS 2008 上以调试模式编译时,一切正常。 当我在发布模式下编译相同的东西时,并非一切都有效。据我所知,包含目录是相同的,并且没有额外的预处理器符号。
有什么帮助吗?
1>zlib.cpp 1>C:\Program Files (x86)\微软 Visual Studio 9.0\VC\include\xutility(419):错误 C2664: 'CryptoPP::AllocatorWithCleanup::AllocatorWithCleanup(const CryptoPP::AllocatorWithCleanup &)' : 无法将参数 1 转换为 'CryptoPP::AllocatorWithCleanup' 到 '常量 CryptoPP::AllocatorWithCleanup &' 1>与 1> [ 1>
T=std::_Aux_cont 1> ] 1>
且1> [ 1>
T=CryptoPP::HuffmanDecoder::CodeInfo 1> ]1>且1> [ 1> T=std::_Aux_cont 1>
]1>原因:无法转换 从 'CryptoPP::AllocatorWithCleanup' 到 '常量 CryptoPP::AllocatorWithCleanup' 1> 与 1> [ 1>
T=CryptoPP::HuffmanDecoder::CodeInfo 1> ]1>且1> [ 1> T=std::_Aux_cont 1>
]1>没有用户定义的转换 可用的操作员可以执行 此转换或运算符 不能称为1> C:\程序 文件 (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:\程序文件 (x86)\微软 Visual Studio 9.0\VC\include\vector(421) :参见类模板参考 实例化 'std::_Container_base_aux_alloc_real<_Alloc>' 正在编译1>与 1>
[ 1>
_Alloc=CryptoPP::AllocatorWithCleanup 1> ]1> C:\程序文件 (x86)\微软 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>
C:\myproject\sshlib\zinflate.h(79) : 请参阅类模板参考 实例化 'std::vector<_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,则它不会编译。为什么?
When I compile on VS 2008 in deubg mode everything works fine.
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.
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>
T=std::_Aux_cont 1> ] 1>
and 1> [ 1>
T=CryptoPP::HuffmanDecoder::CodeInfo
1> ] 1> and 1> [
1> T=std::_Aux_cont 1>
] 1> Reason: cannot convert
from
'CryptoPP::AllocatorWithCleanup' to
'const
CryptoPP::AllocatorWithCleanup' 1>
with 1> [ 1>
T=CryptoPP::HuffmanDecoder::CodeInfo
1> ] 1> and 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>
_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>
[ 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:\myproject\sshlib\zinflate.h(79) :
see reference to class template
instantiation 'std::vector<_Ty,_Ax>'
being compiled 1> with 1>
[ 1>
_Ty=CryptoPP::HuffmanDecoder::CodeInfo,
1>
_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. If I change my release config to have _DEBUG isntead it compiles. Why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是 Visual C++ 编译器中的一个错误。请参阅http://old.nabble.com/-jira--创建:-%28QPID-1458%29-C%2B%2B-common-compile-error-in-VC9 -发布模式-td20469700.html。
您可以通过禁用检查的迭代器:
但请注意:如果您链接到启用了
_SECURE_SCL
编译的第三方库,例如 提升,内存损坏可能(并且将会)发生。It's a bug in the Visual C++ compiler. See http://old.nabble.com/-jira--Created:-%28QPID-1458%29-C%2B%2B-common-compile-error-in-VC9-Release-mode-td20469700.html.
You can work around it by disabling checked iterators:
But be warned: if you link against a third-party library that was compiled with
_SECURE_SCL
enabled, like e.g. boost, memory corruption can (and will) occur.多年后回到 C++,我遇到了类似的错误。事实证明,它与此错误无关,而与我没有将发布配置更新为与调试配置中使用的设置相同的事实有关!因此,对于其他菜鸟来说,请记住确保您的所有配置具有相同的字符集、CLR 支持、包含目录、附加依赖项等。
Coming back to C++ after many years, I encountered a similar error. 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! 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.