Bug: b/258408932 Change-Id: Ib96f39fe0c3912f9746bcc09d079097a145d6115 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/290987 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Artem Titov <titovartem@webrtc.org> Cr-Commit-Position: refs/heads/main@{#39205}
1.2 KiB
1.2 KiB
.h and .cc files come in pairs
This is an overflow page for this style rule.
Example violations
Example violations, which should be avoided in new code:
- Declarations in
path/to/include/foo.h, definitions inpath/to/source/foo.cc. Fix: The.hand.ccfiles should be in the same directory. - Declarations in
foo.h, definitions in bothfoo_bar.ccandfoo_baz.cc. Fix: The.hand.ccfiles should come in pairs, so either splitfoo.hintofoo_bar.handfoo_baz.h, or mergefoo_bar.ccandfoo_baz.ccintofoo.cc.
Exception for platform-specific code
If the functions in a header file need different implementations for different platforms, we allow the following arrangement:
- Declarations in
foo.h. - A complete set of matching definitions in
foo_win.cc, another complete set of matching definitions infoo_mac.cc, and so on. - As per the main rule, these files should all be in the same
directory and in the same build target. The build target should use
platform conditionals to ensure that exactly one of the
.ccfiles are included.