2012-03-21 51 views
0

我嘗試使用下面的C得到一個進程的內存空間++代碼C++ Visual Studio中, 'vc_attributes :: YesNoMaybe': '枚舉' 類型的重定義錯誤

#include "stdafx.h" 
#include <windows.h> 
#include <stdio.h> 
#include <psapi.h> 

void PrintMemoryInfo(DWORD processID) 
{ 
    HANDLE hProcess; 
    PROCESS_MEMORY_COUNTERS pmc; 

    // Print the process identifier. 

    printf("\nProcess ID: %u\n", processID); 

    // Print information about the memory usage of the process. 

    hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | 
          PROCESS_VM_READ, 
          FALSE, 
          processID); 
    if (NULL == hProcess) 
     return; 

    if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc))) 
    { 
     printf("\tPageFaultCount: 0x%08X\n", pmc.PageFaultCount); 
     printf("\tYour app's PEAK MEMORY CONSUMPTION: 0x%08X\n", 
        pmc.PeakWorkingSetSize); 
     printf("\tYour app's CURRENT MEMORY CONSUMPTION: 0x%08X\n", pmc.WorkingSetSize); 
     printf("\tQuotaPeakPagedPoolUsage: 0x%08X\n", 
        pmc.QuotaPeakPagedPoolUsage); 
     printf("\tQuotaPagedPoolUsage: 0x%08X\n", 
        pmc.QuotaPagedPoolUsage); 
     printf("\tQuotaPeakNonPagedPoolUsage: 0x%08X\n", 
        pmc.QuotaPeakNonPagedPoolUsage); 
     printf("\tQuotaNonPagedPoolUsage: 0x%08X\n", 
        pmc.QuotaNonPagedPoolUsage); 
     printf("\tPagefileUsage: 0x%08X\n", pmc.PagefileUsage); 
     printf("\tPeakPagefileUsage: 0x%08X\n", 
        pmc.PeakPagefileUsage); 
    } 

    CloseHandle(hProcess); 
} 

int main() 
{ 
    PrintMemoryInfo(GetCurrentProcessId()); 

    return 0; 
} 

卻得到了這樣的錯誤

Error 2 error C2011: 'vc_attributes::YesNoMaybe' : 'enum' type redefinition 
Error 3 error C2011: 'vc_attributes::AccessType' : 'enum' type redefinition 
Error 4 error C2011: 'vc_attributes::Pre' : 'struct' type redefinition 
Error 5 error C3094: 'repeatable': anonymous usage not allowed 
... 

如何解決這個問題,我正在使用visual studio 2008

+0

由於某種原因,vc/include/sourceannotations.h頭文件中的#pragma一次不起作用。很難猜測爲什麼,請確保您沒有意外更改文件。 – 2012-03-21 00:48:16

回答

2

嘗試清理並重建整個解決方案。有幾個類似的錯誤報告,如here,顯然的解決方案是重建。