Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DT_DIR undefined

Tags:

c

readdir

c99

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
like image 701
RiaD Avatar asked Jan 17 '23 12:01

RiaD


1 Answers

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
like image 101
Mat Avatar answered Jan 29 '23 04:01

Mat