pcl icon indicating copy to clipboard operation
pcl copied to clipboard

Usage of glibc's d_type in struct dirent

Open bytebat opened this issue 7 years ago • 4 comments

Environment

  • Operating System and version: Ubuntu 18.04
  • Compiler: Cross Compilation for QNX 7.0 | qcc (gcc 5.4.0)
  • PCL Version: 1.8.1
  • Buildsystem: cmake 3.10.2

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 uses d_type extension for struct 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).

bytebat avatar Mar 05 '19 09:03 bytebat

Ough, this function looks horrible. We should use boost::filesystem instead.

taketwo avatar Mar 05 '19 09:03 taketwo

any hints about how to start in this issue ?

omar-bakr avatar Feb 25 '20 14:02 omar-bakr

Can be closed I guess, since this bug should have been resolved with #3676

shrijitsingh99 avatar Feb 27 '20 21:02 shrijitsingh99

Fixed by #3676

kunaltyagi avatar Feb 28 '20 01:02 kunaltyagi