【发布时间】:2014-02-13 17:20:23
【问题描述】:
操作系统: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 : "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;
}
【问题讨论】:
-
与所问的问题无关:您的包含中缺少 。
-
你在 hello world 程序中是否遇到同样的错误?如果是这样,它与dirent.h无关。根据msdn.microsoft.com/en-us/library/windows/desktop/…,Windows 等效项是 FindFirstFile、FindNext、FindClose