![](/img/trans.png)
[英]VS2008 SP1 hot-fixes for C++ development: where can I found a comprehensive list?
[英]Visual C++ linker crashes (VS2008 SP1)
以下代碼用於生成素數,在運行調試時按預期編譯和運行,但在發布模式下構建時似乎總是使墨跡崩潰:
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <iostream>
template<typename T> class PrimeGen {
struct Elim {
T p ;
T e ;
} ;
class Elim_cmp {
public:
bool operator()(const Elim& e1, const Elim& e2) { return e1.e > e2.e; }
} ;
std::vector<Elim> elim_heap ;
T last ;
public:
PrimeGen() {
Elim e0 = { 2, 4 } ;
elim_heap.reserve(1024) ;
elim_heap.push_back(e0) ;
last = 2 ;
}
T next() {
T n = last ;
bool prime;
do {
n ++ ;
prime = true ;
while(n == elim_heap.front().e) {
if(prime) prime = false ;
std::pop_heap(elim_heap.begin(), elim_heap.end(), Elim_cmp()) ;
Elim& elim = elim_heap.back() ;
elim.e = elim.p + n ;
std::push_heap(elim_heap.begin(), elim_heap.end(), Elim_cmp()) ;
}
} while(!prime) ;
Elim e = { n, 2*n } ;
elim_heap.push_back( e ) ;
std::push_heap(elim_heap.begin(), elim_heap.end(), Elim_cmp()) ;
return last = n ;
}
} ;
int main()
{
using namespace std ;
PrimeGen<unsigned int> pgen ;
for(int i=0; i<100; i++) {
cout << pgen.next() << endl ;
}
system("pause") ;
}
誰能明白為什么會發生這種情況? 或者我是否遇到過編譯器而不是代碼應該受到責備的罕見情況之一?
我得到的錯誤如下:
error PRJ0002 : Error result -1073741819 returned from 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\mt.exe'.
如果其他運行 Visual Studio 的人花時間嘗試在發布模式下構建代碼(我已經刪除了任何外部依賴項,所以它應該只是 c&p),我將非常感激。
更新:經過進一步審查,即使對於簡單的“Hello World”代碼,mt.exe 似乎在發布模式下對我來說一直崩潰,所以我的安裝肯定有問題。 我將重新安裝所有希望能解決這個問題的東西。 版主,請隨時關閉此問題。
某些程序(例如防病毒程序)正在掃描 file.exe,同時 linker 正在嘗試嵌入清單文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.