I'm writing a C program using Eclipse CDT. I want to init my for loops like this ...
for( int i = 0; i < 5; i++ )
so I added -std=c99 to the gcc command line. This has the side effect of throwing the error: ‘DT_REG’ undeclared (first use in this function) for the line:
if( dir_ent->d_type != DT_REG )
DT_REG is defined in dirent.h (which is included). The code compiles fine without -std=c99 on the gcc command line. What am I missing?
What happens with -std=gnu99
? It looks like the d_type
field is non-standard (see the GNU libc manual page "Directory Entries") and so the enum that represents the directory entry types is disabled in strictly compliant mode. It looks like you need to define _BSD_SOURCE
(or _GNU_SOURCE
) to get the type values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With