0

操作系统:Windows 8 64 位

编译器:Visual Studio 2012

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

错误消息:C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(146):致命错误 C1189:#error:“无目标体系结构”

例子:

#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;  
} 
4

1 回答 1

0

我有同样的问题...尝试去 PROJECT-> PROPERTIES -> Configuration Properties -> C/C++ -> Preprocessor,然后在 Preprocessor Definitions 添加AMD64。这个对我有用。PS 在 AMD64 前后加上下划线。

于 2014-03-15T19:26:53.070 回答