atilaneves / dpp

Directly include C headers in D source code
Boost Software License 1.0
227 stars 31 forks source link

Fix #307 - not to resolve include path if possible #313

Closed tom-tan closed 1 year ago

tom-tan commented 1 year ago

It is caused by the combination of system include paths and the use of #include_next directive in the system headers.

In the example I shown in the issue, the dpp first resolves stdint.h to /usr/lib/llvm-10/lib/clang/10.0.0/include/stdint.h and tries to expand it. However, #include_next <stdint.h> directive in /usr/lib/llvm-10/lib/clang/10.0.0/include/stdint.h accidentally includes the same header and failed to include /usr/include/stdint.h (it is intended to be included) due to the include guard.

This request fixes this issue by not to resolve the header path if it is in the system paths or specified include paths.

atilaneves commented 1 year ago

This needs a test.

tom-tan commented 1 year ago

Done!

I used CPATH rather than using --include-path because the headers added by the latter are not treated as system headers by clang.systemPaths. I added a fallback for preprocessors that does not support include_next because this directive is platform dependent, I guess.

atilaneves commented 1 year ago

Red CI.

tom-tan commented 1 year ago

I accidentally closed this issue but reopened it.

tom-tan commented 1 year ago

Thanks!