C++ Visual Studio, 'vc_attributes::YesNoMaybe' : 'enum' type redefinition error

标签 c++ visual-studio-2008 winapi visual-c++

我正在尝试使用以下 C++ 代码获取进程的内存空间

#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

最佳答案

尝试清理并重建整个解决方案。有一些类似错误的报告,例如 here ,明显的解决方案是重建。

关于C++ Visual Studio, 'vc_attributes::YesNoMaybe' : 'enum' type redefinition error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9796906/

相关文章:

c# - 如何在C++项目中使用DLL库文件?

c++ - 是否可以在构造函数之前调用 C++ 对象实例的析构函数?如果是这样,如何?

visual-studio-2008 - Visual C++ 测试问题

c++ - 如何正确使用QMediaMetaData定义媒体文件参数?

c++ - 在 Visual Studio 中链接到版本中的库和调试中的 .exe 崩溃

c++ - 线程已退出,代码为 1 (0x1)

windows - 来自网络URL的DirectShow RenderFile具有严重缺陷。如何避免呢?

delphi - WinAPI -> CryptoAPI -> RSA,用私有(private)加密,用公共(public)解密

c++ - 这段 C++ CRTP 代码应该编译吗?如果可以,它应该做什么?

c++ - 用于简单数组创建和 i/o 的 C vs C++ 代码优化