--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAH%3DT95SNPLpJPnE%2Bk0i7gPinAn6a5KG95EX%3D3phdtgJW826P%2BQ%40mail.gmail.com.
Chrome's style guide recommends forward declarations over includes (https://chromium.googlesource.com/chromium/src/+/main/styleguide/c++/c++.md#forward-declarations-vs_includes), and there are some forward-only headers like "callback_forward.h" to facilitate this.IIUC the generated mojo code for foo.mojom creates "foo.mojom-forward.h", which has only forwards, and "foo.mojom.h" which has the full definitions. So by the spirit of the style guide, header files should #include mojom-forward.h files where possible. But I can't find this explicitly documented anywhere.Should we update https://chromium.googlesource.com/chromium/src/+/main/styleguide/c++/c++.md#forward-declarations-vs_includes to explicity recommend .mojom-forward.h files?
Come to think of it, is it worth explicitly mentioning forwarding headers like "callback_forward.h"?
I think you're right that forwarding headers are preferred when they suffice. I am ambivalent towards explicitly mentioning that (I don't think it will change behavior much).I would love to see a limited form of misc-include-cleaner or IWYU suggest these automatically where applicable.
Come to think of it, is it worth explicitly mentioning forwarding headers like "callback_forward.h"?Maybe as this one is particularly widespread, but don't want to maintain a list of such headers in the style guide either. Maybe a big "USE THE FORWARDING HEADER IN HEADERS" at the top of callback.h would do more?