Skip to content

Commit

Permalink
Add a common mistake case for header-only classes in components build…
Browse files Browse the repository at this point in the history
… doc

R=brettw@chromium.org

Review-Url: https://codereview.chromium.org/2686133003
Cr-Commit-Position: refs/heads/master@{#451390}
  • Loading branch information
majido authored and Commit bot committed Feb 17, 2017
1 parent 2e04487 commit e0ee33c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/component_build.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,12 @@ the object file might not be brought into the link. Even if it is brought in
today, it might not be brought in due to completely unrelated changes in the
future. The result will be undefined symbol errors from other components. Use
source sets if your component is made up of more than one target.

### Exporting functions and classes implemented in headers

When you implement a symbol in a header the compiler will put that in every
necessary translation unit and the linker will pick one. If the symbol is never
referenced by code in the shared library it's supposed exported from, it will
never be instantiated and never exported. The result will be undefined external
symbol errors when linking. Exported symbols should be declared in a header but
always implemented in a .cc file.

0 comments on commit e0ee33c

Please sign in to comment.