2010-10-07 74 views
0

當我在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

回答

2

這是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

0

多年後回到C++,我遇到了類似的錯誤。原來,這與這個bug無關,與我沒有將Release配置更新爲Debug配置中使用的相同設置有關。因此,對於其他noobs - 請記住確保在所有配置中具有相同的字符集,CLR支持,包含目錄,附加依賴關係等。

相關問題