atilaneves / dpp

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

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

Closed tom-tan closed 2 years ago

tom-tan commented 2 years 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 2 years ago

This needs a test.

tom-tan commented 2 years 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 2 years ago

Red CI.

tom-tan commented 2 years ago

I accidentally closed this issue but reopened it.

tom-tan commented 2 years ago

Thanks!