Replies: 1 comment
-
Old guidelines In cpp files, include pch.h first (do not include pch.h in header files) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
ModernLife will use pre-compiled headers via pch.cpp and pch.h.
Each file should include what it uses, and nothing else: https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/WhyIWYU.md. This means that when a header is added to pch.h it should NOT be removed from the .cpp or .h file that needs it. This makes dependencies of a class unclear and can break refactoring and reuse. If someone wants to use a class you wrote their project (that has a different pch.h, or doesn't use PCH), you have caused them pain.
Header files will use #prgama once as a header guard.
Guidelines for headers and includes are:
Cpp file only:
Cpp and H files:
Example CPP
Example H file
Testing
You should test (with 'using precompiled header' off and an empty pch.h that your files build correctly. Generated files and included Windows or WinRT files may not. Those are problems for my friends at Microsoft to fix.
Sources
Google C++ Style Guide, specifically
https://google.github.io/styleguide/cppguide.html#Names_and_Order_of_Includes
https://google.github.io/styleguide/cppguide.html#Windows_Code
Beta Was this translation helpful? Give feedback.
All reactions