开发者

Error compiling in release mode but not in debug mode

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 '开发者_如何学GoCryptoPP::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?


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:

#define _SECURE_SCL 0

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜