在64位窗口上使用dirent.h编译错误

时间:2014-02-13 17:20:23

标签: c++ windows dirent.h

操作系统:Windows 8 64位

编译器:Visual Studio 2012

问题描述:当我尝试使用“x64”中的“dirent.h”编译代码时,会发生错误。无论是否使用dirent.h。如果代码是在“win32”设置下编译的,则不会发生错误。

错误MSG:C:\ Program Files(x86)\ Windows Kits \ 8.0 \ Include \ um \ winnt.h(146):致命错误C1189:#error:“No Target Architecture”

实施例

#include stdio.h  
#include sys/types.h
#include dirent.h   

int main(int argc, char* argv[])  
{  

    const char *name = ".";  
    DIR *dirp;  
    struct dirent *dp;  

    dirp = opendir(name);  
    if (dirp != NULL) {  
        printf("opendir %s succeed!\n", name);    
    }  
    closedir(dirp);  
    return 0;  
} 

1 个答案:

答案 0 :(得分:0)

我有同样的问题...尝试去PROJECT->特性 - >配置属性 - > C / C ++ - >预处理器和预处理器定义中添加 AMD64 。这个对我有用。 PS在AMD64之前和之后加下下划线。