Include what you use pass on headers#474
Conversation
|
nudge @jennybc :) |
|
I don't really look after xml2. Am I forgetting something I signed up to do here? |
|
I may have picked a bad repo to start -- but my memory from the tidyteam meeting in February is that you were keen on doing this header clean-up for tidyverse+adjacent packages. CMIIW, or if you'd prefer to see this pilot exercise on some specific repos instead. Thanks! |
|
After giving this some more thought but I'm not so sure anymore it's a good idea to do this everywhere. I agree that it might be good to scan your package for API headers that you forgot to include, and which happen to be included transitively in a way that might not be guaranteed to keep working. However the opposite is also true: many libraries have an API header (that you are supposed to include in the app) and this header then transitively includes some implementation headers, which might be platform/version specific. So the portable solution is to include the API header only. In those cases enforcing that we include the implementation header might actually be counter productive in some cases. For example in the case of this PR, I think we are supposed to include |
|
I do think there are tradeoffs in both directions -- certainly, that the ecosystem generally works by just including FWIW, my understanding is this is also more of a C++ thing for Anyway, within R as of today it's really more a matter of taste than correctness. |
Following up the tidyteam meeting today with a first suggested PR as an earmark/test balloon lest I forget. A few notes:
<cstddef>forNULLgave me a bit of pause becausesrc/init.cuses<stdlib.h>for that. I think this is partly just a C vs. C++ thing, e.g. https://stackoverflow.com/q/12023476/3576984; we might consider<stddef.h>for a narrower inclusion in init.c.