Skip to content

Commit

Permalink
Dawg: Define virtual destructor in .cpp file
Browse files Browse the repository at this point in the history
This fixes compiler warnings from clang:

src/dict/dawg.h:119:7: warning:
 'Dawg' has no out-of-line virtual method definitions;
 its vtable will be emitted in every translation unit [-Wweak-vtables]

Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Sep 4, 2018
1 parent ac8afc5 commit 0d211f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/dict/dawg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
----------------------------------------------------------------------*/
namespace tesseract {

// Destructor.
// It is defined here, so the compiler can create a single vtable
// instead of weak vtables in every compilation unit.
Dawg::~Dawg() = default;

bool Dawg::prefix_in_dawg(const WERD_CHOICE &word,
bool requires_complete) const {
if (word.length() == 0) return !requires_complete;
Expand Down
2 changes: 1 addition & 1 deletion src/dict/dawg.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class Dawg {
inline const STRING &lang() const { return lang_; }
inline PermuterType permuter() const { return perm_; }

virtual ~Dawg() = default;
virtual ~Dawg();

/// Returns true if the given word is in the Dawg.
bool word_in_dawg(const WERD_CHOICE &word) const;
Expand Down

0 comments on commit 0d211f9

Please sign in to comment.