This is an overflow page for this style rule.
Example violations, which should be avoided in new code:
- Declarations in
path/to/include/foo.h
, definitions inpath/to/source/foo.cc
. Fix: The.h
and.cc
files should be in the same directory. - Declarations in
foo.h
, definitions in bothfoo_bar.cc
andfoo_baz.cc
. Fix: The.h
and.cc
files should come in pairs, so either splitfoo.h
intofoo_bar.h
andfoo_baz.h
, or mergefoo_bar.cc
andfoo_baz.cc
intofoo.cc
.
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
.cc
files are included.