DT_DIR undefined

十年热恋 提交于 2019-12-10 17:09:24

问题


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

回答1:


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


来源:https://stackoverflow.com/questions/9241538/dt-dir-undefined

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!