cxong / tinydir

Lightweight, portable and easy to integrate C directory and file reader

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compilation fails with -std=c99

cxong opened this issue · comments

commented
/home/cxu/test/tinydir/samples/../tinydir.h: In function ‘tinydir_open’:
/home/cxu/test/tinydir/samples/../tinydir.h:212:10: error: implicit declaration of function ‘readdir_r’ [-Werror=implicit-function-declaration]
  error = readdir_r(dir->_d, dir->_ep, &dir->_e);
          ^
/home/cxu/test/tinydir/samples/../tinydir.h: In function ‘_tinydir_dirent_buf_size’:
/home/cxu/test/tinydir/samples/../tinydir.h:654:13: error: #error "buffer size for readdir_r cannot be determined"
 #           error "buffer size for readdir_r cannot be determined"
             ^
cc1: all warnings being treated as errors
make[2]: *** [CMakeFiles/file_open_sample.dir/file_open_sample.c.o] Error 1
make[1]: *** [CMakeFiles/file_open_sample.dir/all] Error 2
make: *** [all] Error 2

In particular, the _tinydir_dirent_buf_size function needs fixing as it is relying on preprocessor flags that haven't been defined like HAVE_FPATHCONF.

commented

Should have RTFM... http://linux.die.net/man/3/readdir_r
readdir_r requires various feature macros to be set, as it is a POSIX rather than a standard C function.