Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage of glibc's d_type in struct dirent #2888

Closed
bytebat opened this issue Mar 5, 2019 · 4 comments
Closed

Usage of glibc's d_type in struct dirent #2888

bytebat opened this issue Mar 5, 2019 · 4 comments
Labels
good first issue Skills/areas of expertise needed to tackle the issue kind: bug Type of issue module: io

Comments

@bytebat
Copy link

bytebat commented Mar 5, 2019

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).

@taketwo
Copy link
Member

taketwo commented Mar 5, 2019

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

@taketwo taketwo added good first issue Skills/areas of expertise needed to tackle the issue module: io labels Mar 5, 2019
@omar-bakr
Copy link

any hints about how to start in this issue ?

@shrijitsingh99
Copy link
Contributor

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

@kunaltyagi
Copy link
Member

Fixed by #3676

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Skills/areas of expertise needed to tackle the issue kind: bug Type of issue module: io
Projects
None yet
Development

No branches or pull requests

5 participants