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

Make #includes match C++ Core Guidelines #80

Closed
javagl opened this issue Dec 15, 2020 · 4 comments
Closed

Make #includes match C++ Core Guidelines #80

javagl opened this issue Dec 15, 2020 · 4 comments
Labels
good first issue Good for newcomers quality Improve code quality or encourage developer success

Comments

@javagl
Copy link
Contributor

javagl commented Dec 15, 2020

There currently are some subtle inconsistencies regarding include directives. Specifically, the pattern of brackets/quotes for <system_includes> and "own_includes" is not applied consistently. The relevant comment that summarizes this is at #56 (comment)

This should be fixed, preferably in one, dedicated cleanup step.

@javagl
Copy link
Contributor Author

javagl commented Dec 17, 2020

When this is addressed, the include strategy in cesium-unreal should also be reviewed. The Unreal headers are heavily confused by any windows header that may be included before them (meaning that having any include that (transitively) includes a windows header may cause hundreds of compile errors). One strategy for alleviating this might be to 1. first include all Unreal headers, 2. then include system includes, 3, then include "internal" includes. C.f. https://google.github.io/styleguide/cppguide.html#Names_and_Order_of_Includes

@kring
Copy link
Member

kring commented Dec 17, 2020

Yeah Unreal gets really grumpy when we include Windows header. I don't think changing the order of includes will solve it, because source code using Unreal types has issues too, it's not just the Unreal headers that are a problem.

In general we shouldn't have any reason to include windows.h in any header. Unreal has portable versions of most of what we'd want to use from windows.h anyway. If we need something unusual, including windows.h in a .cpp that doesn't depend on Unreal is fine. The reason we ran into problems with spdlog is because it has weird defaults that make it so that #include <spdlog/spdlog.h> without definining SPDLOG_COMPILED_LIB (or probably others if we're going for header-only) causes the entire implementation to be dumped into the header, and the implementation requires windows.h.

I'm mostly writing this down for future reference, because it was a pain to figure out.

@kring kring changed the title Review the include strategy Apr 27, 2021
@kring kring added the quality Improve code quality or encourage developer success label Apr 27, 2021
@kring
Copy link
Member

kring commented Apr 27, 2021

I've changed the title to reflect the fact that the action here is to move cesium-native to the include strategy recommended in the C++ Core Guidelines: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#sf12-prefer-the-quoted-form-of-include-for-files-relative-to-the-including-file-and-the-angle-bracket-form-everywhere-else

More detail here: #56 (comment)
And here: #56 (comment)

@kring kring changed the title Make includes match C++ Core Guidelines Apr 27, 2021
@kring kring added the good first issue Good for newcomers label Apr 27, 2021
@kring kring added this to To do in Cesium for Unreal Apr 28, 2021
@kring kring moved this from To do to Needs Triage in Cesium for Unreal Jun 29, 2021
@kring kring removed this from Needs Triage in Cesium for Unreal Jun 29, 2021
@kring
Copy link
Member

kring commented May 9, 2022

We've now done this, more or less. We should write issues for any remaining issues as we find them (or just fix them), but we can close this issue.

@kring kring closed this as completed May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers quality Improve code quality or encourage developer success
2 participants