DT_DIR 未定义
我想检查 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
I want to check if file returned by readdir
is directory.
I tried do it using DT_DIR
constant (as man readdir
says) but it's undefined. What file should I include to get it?
Now I use
#include <sys/types.h>
#include <dirent.h>
#include <stdlib.h>
#include <errno.h>
gcc version is 4.6.1
Compilation string:
gcc a.c --std=c99 -Wall
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要定义
_BSD_SOURCE
功能测试宏才能获得这些定义,它们不是标准的,并且 GCC 在编译 C99 时不会定义该宏。You need to have the
_BSD_SOURCE
feature test macro defined to get those defines, they are not standard, and GCC does not define that macro when compiling for C99.