Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想检查返回的文件readdir是否是目录。我尝试使用DT_DIR常量(man readdir如前所述)来做到这一点,但它是未定义的。我应该包含什么文件来获取它?
readdir
DT_DIR
man readdir
现在我用
#include <sys/types.h> #include <dirent.h> #include <stdlib.h> #include <errno.h>
gcc 版本是 4.6.1
编译字符串:
gcc a.c --std=c99 -Wall
您需要_BSD_SOURCE定义功能测试宏才能获得这些定义,它们不是标准的,并且 GCC 在为 C99 编译时没有定义该宏。
_BSD_SOURCE
gcc -std=c99 -D_BSD_SOURCE -Wall a.c