Skip to content

Fix signature of scandir filter callback for Darwin#12

Merged
guillerodriguez merged 1 commit intomasterfrom
fix/scandir-filter-signature
Feb 11, 2026
Merged

Fix signature of scandir filter callback for Darwin#12
guillerodriguez merged 1 commit intomasterfrom
fix/scandir-filter-signature

Conversation

@guillerodriguez
Copy link
Copy Markdown
Contributor

According to POSIX 2008, the scandir filter callback takes a const dirent pointer. The existing code used the const-qualified signature for Linux only, but Darwin requires it too. This caused a warning (-Wincompatible-function-pointer-types) which recent versions of clang treat as a hard error:

error: incompatible function pointer types passing
'int (*)(struct dirent )' to parameter of type
'int (
)(const struct dirent *)'

Fix by using the correct POSIX signature on Darwin as well. The non-const fallback is kept for older non-conforming systems.

According to POSIX 2008, the scandir filter callback takes a
const dirent pointer. The existing code used the const-qualified
signature for Linux only, but Darwin requires it too. This caused
a warning (-Wincompatible-function-pointer-types) which recent
versions of clang treat as a hard error:

  error: incompatible function pointer types passing
         'int (*)(struct dirent *)' to parameter of type
         'int (*)(const struct dirent *)'

Fix by using the correct POSIX signature on Darwin as well.
The non-const fallback is kept for older non-conforming systems.

Signed-off-by: Guillermo Rodríguez <grodriguez@ingelabs.com>
@guillerodriguez guillerodriguez merged commit eff3c53 into master Feb 11, 2026
3 checks passed
@guillerodriguez guillerodriguez deleted the fix/scandir-filter-signature branch February 11, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants