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

Consider using __has_include for glue sources #80

Open
armanbilge opened this issue Jul 31, 2022 · 0 comments
Open

Consider using __has_include for glue sources #80

armanbilge opened this issue Jul 31, 2022 · 0 comments

Comments

@armanbilge
Copy link

armanbilge commented Jul 31, 2022

See Comcast/ip4s@8abd977 for an example.

Motivating case study

Suppose I want to use ip4s which currently needs icu4c, but only for IDN support. Except I don't want to use the IDN features. Unfortunately it is still necessary to have icu4c on my system so the glue code can compile, even if ultimately it will never be linked.

By using the __has_include directive, we can compile the glue sources only if the required headers are present. If the headers are missing and the sources are not compiled, so long as those methods are not called linking can still succeed.

In effect, this makes Native dependencies optional, driven by link-time needs. This reduces the burden on end-users if a library decides to implement some optional features using a native library.

Caveats

Linking errors instead of missing header errors. But perhaps a well written #warning in the else case can draw attention to what's actually going on.

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

No branches or pull requests

1 participant