Skip to content

Commit 46d2273

Browse files
committed
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>
1 parent 68bcd6b commit 46d2273

File tree

4 files changed

+32
-6
lines changed

4 files changed

+32
-6
lines changed

src/training/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ endif()
173173
########################################
174174

175175
set(unicharset_training_src
176+
icuerrorcode.cpp
176177
icuerrorcode.h
177178
lang_model_helpers.cpp
178179
lang_model_helpers.h

src/training/Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ libtesseract_training_la_SOURCES = \
6565
commandlineflags.cpp \
6666
commontraining.cpp \
6767
degradeimage.cpp \
68+
icuerrorcode.cpp \
6869
lang_model_helpers.cpp \
6970
ligature_table.cpp \
7071
lstmtester.cpp \

src/training/icuerrorcode.cpp

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
///////////////////////////////////////////////////////////////////////
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
//
13+
///////////////////////////////////////////////////////////////////////
14+
15+
#include "icuerrorcode.h"
16+
17+
namespace tesseract {
18+
19+
// Destructor.
20+
// It is defined here, so the compiler can create a single vtable
21+
// instead of weak vtables in every compilation unit.
22+
IcuErrorCode::~IcuErrorCode() {
23+
if (isFailure()) {
24+
handleFailure();
25+
}
26+
}
27+
28+
} // namespace tesseract.

src/training/icuerrorcode.h

+2-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Features:
99
* - The constructor initializes the internal UErrorCode to U_ZERO_ERROR,
10-
* removing one common source of errors.
10+
* removing one common source of errors.
1111
* - Same use in C APIs taking a UErrorCode* (pointer) and C++ taking
1212
* UErrorCode& (reference), via conversion operators.
1313
* - Automatic checking for success when it goes out of scope. On failure,
@@ -44,11 +44,7 @@ namespace tesseract {
4444
class IcuErrorCode : public icu::ErrorCode {
4545
public:
4646
IcuErrorCode() {}
47-
virtual ~IcuErrorCode() {
48-
if (isFailure()) {
49-
handleFailure();
50-
}
51-
}
47+
virtual ~IcuErrorCode();
5248

5349
protected:
5450
virtual void handleFailure() const {

0 commit comments

Comments
 (0)