From 0d211f9ed5b583ccff8a8478b8f475b36704cfcf Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Tue, 4 Sep 2018 07:47:29 +0200 Subject: [PATCH] Dawg: Define virtual destructor in .cpp file 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 --- src/dict/dawg.cpp | 5 +++++ src/dict/dawg.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/dict/dawg.cpp b/src/dict/dawg.cpp index db626a4a4b..864e60c866 100644 --- a/src/dict/dawg.cpp +++ b/src/dict/dawg.cpp @@ -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; diff --git a/src/dict/dawg.h b/src/dict/dawg.h index 9c4c09d231..0d3c2f619a 100644 --- a/src/dict/dawg.h +++ b/src/dict/dawg.h @@ -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;