操作系统: Windows 8 64位
编译器: Visual 2012
问题描述:当我试图在"x64“中编译带有"dirent.h”的代码时,会出现错误。不管是脏的还是不使用的。如果代码是在"win32“设置下编译的,则不会发生错误。
错误MSG: C:\程序文件(x86)\Windows \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;
} 发布于 2014-03-15 19:26:53
我也有同样的问题..。尝试转到项目->属性->配置属性-> C/C++ ->预处理器,并在预处理器定义中添加AMD64。对我来说很管用。在AMD64前后放置下划线。
https://stackoverflow.com/questions/21761098
复制相似问题