【问题标题】:compile error with dirent.h on 64bit windows在 64 位 Windows 上使用 dirent.h 编译错误
【发布时间】: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

标签: c++ windows dirent.h


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-24
    • 2018-12-11
    • 2013-08-25
    • 1970-01-01
    • 1970-01-01
    • 2015-01-31
    • 2018-05-22
    • 1970-01-01
    相关资源
    最近更新 更多