简体   繁体   English

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

[英]compile error with dirent.h on 64bit windows

OS: Windows 8 64-bit 操作系统:Windows 8 64-bit

Compiler: Visual Studio 2012 编译器:Visual Studio 2012

Problem Description: When I try to compile codes with "dirent.h" in "x64", error occurs. 问题描述:当我尝试用“ x64”中的“ dirent.h”编译代码时,发生错误。 No matter dirent.h is used or not. 不管是否使用dirent.h。 The error won't occur if the codes were compile under "win32" setting. 如果代码是在“ win32”设置下编译的,则不会发生该错误。

Error MSG: C:\\Program Files (x86)\\Windows Kits\\8.0\\Include\\um\\winnt.h(146): fatal error C1189: #error : "No Target Architecture" 错误MSG:C:\\ Program Files(x86)\\ Windows Kits \\ 8.0 \\ Include \\ um \\ winnt.h(146):致命错误C1189:#error:“无目标体系结构”

EXAMPLE: 例:

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

I had the same problem... Try to go PROJECT-> PROPERTIES -> Configuration Properties -> C/C++ -> Preprocessor, and in Preprocessor Definitions add AMD64 . 我遇到了同样的问题...尝试去PROJECT-> PROPERTIES-> Configuration Properties-> C / C ++-> Preprocessor,并在Preprocessor Definitions中添加AMD64 It works for me. 这个对我有用。 PS put underscore before and after AMD64. PS在AMD64之前和之后都强调。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM