Keep headers “composition-safe” and minimal. Apply these rules:
.cpp file to avoid multiple-definition/linker problems.constexpr, enum, or an internal-scoped construct rather than a global #define.Example (bad → good):
// bad: in header
// foo.h
int gettimeofday_impl(); // ...
int gettimeofday_impl() { return 0; } // implementation in header
// good: in header
// foo.h
int gettimeofday_impl();
// foo.cpp
int gettimeofday_impl() { return 0; }
Checklist for changes to .h files:
inline) in the header?#define entries?Enter the URL of a public GitHub repository