Usage of glibc's d_type in struct dirent #2888
Labels
good first issue
Skills/areas of expertise needed to tackle the issue
kind: bug
Type of issue
module: io
Environment
Context
I try to cross-compile the PCL for QNX. I get the following error(s) in the common module when doing this:
<pcldir>/common/include/pcl/common/impl/file_io.hpp:55:17: error: 'struct dirent' has no member named 'd_type' if (dirp->d_type == DT_REG) // Only regular files
and
<pcldir>/common/include/pcl/common/impl/file_io.hpp:55:27: error: 'DT_REG' was not declared in this scope if (dirp->d_type == DT_REG) // Only regular files
Expected Behavior
There should be no compile errors ;-) ... Or at least it would be nice to go for a standard POSIX way of regular file checking.
Current Behavior
The problem occurs in the
getAllPcdFilesInDirectory
function which usesd_type
extension forstruct dirent
from glibc, which is not provided on my target system.Code to Reproduce
The whole QNX toolchain needs to be set up for this to reproduce. Indeed the problem can be reproduced with any other compiler/toolchain which does not provide the non-glibc version of struct dirent with the d_type / DT_REG definition.
Possible Solution
I suggest to fix this by providing a fallback for systems without glibc (i.e. by checking for _DIRENT_HAVE_D_TYPE and using pure POSIX's S_ISREG() macro instead).
The text was updated successfully, but these errors were encountered: