You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.The text was updated successfully, but these errors were encountered: