From 5b8162f0efdd7acde6fd9fec8ed5df3888b25bb8 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Tue, 4 Sep 2018 07:44:27 +0200 Subject: [PATCH] CCUtil: Define virtual destructor in .cpp file This fixes compiler warnings from clang: src/ccutil/ccutil.h:51:7: warning: 'CCUtil' 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/ccutil/ccutil.cpp | 5 +++++ src/ccutil/ccutil.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ccutil/ccutil.cpp b/src/ccutil/ccutil.cpp index e33bda47..32e82c75 100644 --- a/src/ccutil/ccutil.cpp +++ b/src/ccutil/ccutil.cpp @@ -27,6 +27,11 @@ CCUtil::CCUtil() : " whether to adapt to a character", ¶ms_) { } +// Destructor. +// It is defined here, so the compiler can create a single vtable +// instead of weak vtables in every compilation unit. +CCUtil::~CCUtil() = default; + CCUtilMutex::CCUtilMutex() { #ifdef _WIN32 mutex_ = CreateMutex(0, FALSE, 0); diff --git a/src/ccutil/ccutil.h b/src/ccutil/ccutil.h index fd1b9f83..0cf35ff7 100644 --- a/src/ccutil/ccutil.h +++ b/src/ccutil/ccutil.h @@ -51,7 +51,7 @@ class CCUtilMutex { class CCUtil { public: CCUtil(); - virtual ~CCUtil() = default; + virtual ~CCUtil(); public: // Read the arguments and set up the data path.