From 14c23c9f13af1f5ff2def3db6286bf4c29623f28 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Tue, 4 Sep 2018 07:43:17 +0200 Subject: [PATCH] MATRIX: Define virtual destructor in .cpp file This fixes compiler warnings from clang: src/ccstruct/matrix.h:575:7: warning: 'MATRIX' 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/ccstruct/matrix.cpp | 5 +++++ src/ccstruct/matrix.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/ccstruct/matrix.cpp b/src/ccstruct/matrix.cpp index 28598745..678d412c 100644 --- a/src/ccstruct/matrix.cpp +++ b/src/ccstruct/matrix.cpp @@ -32,6 +32,11 @@ #include "tprintf.h" #include "unicharset.h" +// Destructor. +// It is defined here, so the compiler can create a single vtable +// instead of weak vtables in every compilation unit. +MATRIX::~MATRIX() = default; + // Returns true if there are any real classification results. bool MATRIX::Classified(int col, int row, int wildcard_id) const { if (get(col, row) == NOT_CLASSIFIED) return false; diff --git a/src/ccstruct/matrix.h b/src/ccstruct/matrix.h index 953c3e37..6feec223 100644 --- a/src/ccstruct/matrix.h +++ b/src/ccstruct/matrix.h @@ -577,6 +577,8 @@ class MATRIX : public BandTriMatrix { MATRIX(int dimension, int bandwidth) : BandTriMatrix(dimension, bandwidth, NOT_CLASSIFIED) {} + virtual ~MATRIX(); + // Returns true if there are any real classification results. bool Classified(int col, int row, int wildcard_id) const;