Skip to content

Commit

Permalink
IcuErrorCode: Define virtual destructor in .cpp file
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
stweil committed Sep 4, 2018
1 parent 68bcd6b commit 46d2273
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/training/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ endif()
########################################

set(unicharset_training_src
icuerrorcode.cpp
icuerrorcode.h
lang_model_helpers.cpp
lang_model_helpers.h
Expand Down
1 change: 1 addition & 0 deletions src/training/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
28 changes: 28 additions & 0 deletions src/training/icuerrorcode.cpp
Original file line number Diff line number Diff line change
@@ -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.
8 changes: 2 additions & 6 deletions src/training/icuerrorcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 46d2273

Please sign in to comment.