DT_DIR未定义 [英] DT_DIR undefined
本文介绍了DT_DIR未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要检查如果 READDIR
返回文件目录。
我试着用 DT_DIR
常数(如男人READDIR
说的)做的,但它是不确定的。我应该包括哪些文件得到它?
现在我用
的#include< SYS / types.h中>
#包括LT&;&dirent.h GT;
#包括LT&;&stdlib.h中GT;
#包括LT&;&errno.h中GT;
gcc版本4.6.1是
编辑字符串:
GCC交流转换器--std = C99 -Wall
解决方案
您需要有定义让那些定义了 _BSD_SOURCE
功能测试宏,它们不规范,和编译为C99时,GCC没有定义宏。
的gcc -std = C99 -D_BSD_SOURCE -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
解决方案
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.
gcc -std=c99 -D_BSD_SOURCE -Wall a.c
这篇关于DT_DIR未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文