IcuErrorCode: Define virtual destructor in .cpp file

This fixes compiler warnings from clang:

src/training/icuerrorcode.h:44:7: warning:
 'IcuErrorCode' has no out-of-line virtual method definitions;
 its vtable will be emitted in every translation unit [-Wweak-vtables]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2018-09-04 07:57:05 +02:00
parent 68bcd6ba90
commit 46d2273e82
4 changed files with 32 additions and 6 deletions

View File

@ -173,6 +173,7 @@ endif()
########################################
set(unicharset_training_src
icuerrorcode.cpp
icuerrorcode.h
lang_model_helpers.cpp
lang_model_helpers.h

View File

@ -65,6 +65,7 @@ libtesseract_training_la_SOURCES = \
commandlineflags.cpp \
commontraining.cpp \
degradeimage.cpp \
icuerrorcode.cpp \
lang_model_helpers.cpp \
ligature_table.cpp \
lstmtester.cpp \

View File

@ -0,0 +1,28 @@
///////////////////////////////////////////////////////////////////////
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///////////////////////////////////////////////////////////////////////
#include "icuerrorcode.h"
namespace tesseract {
// Destructor.
// It is defined here, so the compiler can create a single vtable
// instead of weak vtables in every compilation unit.
IcuErrorCode::~IcuErrorCode() {
if (isFailure()) {
handleFailure();
}
}
} // namespace tesseract.

View File

@ -7,7 +7,7 @@
*
* Features:
* - The constructor initializes the internal UErrorCode to U_ZERO_ERROR,
* removing one common source of errors.
* removing one common source of errors.
* - Same use in C APIs taking a UErrorCode* (pointer) and C++ taking
* UErrorCode& (reference), via conversion operators.
* - Automatic checking for success when it goes out of scope. On failure,
@ -44,11 +44,7 @@ namespace tesseract {
class IcuErrorCode : public icu::ErrorCode {
public:
IcuErrorCode() {}
virtual ~IcuErrorCode() {
if (isFailure()) {
handleFailure();
}
}
virtual ~IcuErrorCode();
protected:
virtual void handleFailure() const {