Fixed XXX has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit in Exception and derived classes

Enabled -Wall and -Wextra
This commit is contained in:
Alexander Stillich 2018-11-05 14:50:45 +01:00
parent 83e1075792
commit d2242ac24a
27 changed files with 231 additions and 51 deletions

View File

@ -2,6 +2,8 @@ QT += qml quick
CONFIG += c++11 qzxing_qml CONFIG += c++11 qzxing_qml
gcc:QMAKE_CXXFLAGS += -Wall -Wextra
SOURCES += main.cpp SOURCES += main.cpp
RESOURCES += qml.qrc RESOURCES += qml.qrc

View File

@ -4,6 +4,8 @@ VERSION = 1.1.0
QT += declarative network QT += declarative network
gcc:QMAKE_CXXFLAGS += -Wall -Wextra
!maemo5 { !maemo5 {
contains(QT_CONFIG, opengl) { contains(QT_CONFIG, opengl) {
# QT += opengl # QT += opengl

View File

@ -7,6 +7,8 @@ QT += widgets
CONFIG += qzxing_qml CONFIG += qzxing_qml
gcc:QMAKE_CXXFLAGS += -Wall -Wextra
# Additional import path used to resolve QML modules in Creator's code model # Additional import path used to resolve QML modules in Creator's code model
QML_IMPORT_PATH = QML_IMPORT_PATH =

View File

@ -2,6 +2,8 @@ TEMPLATE = app
CONFIG += c++11 qzxing_multimedia CONFIG += c++11 qzxing_multimedia
gcc:QMAKE_CXXFLAGS += -Wall -Wextra
CONFIG(debug, debug|release) { CONFIG(debug, debug|release) {
CONFIG+=qml_debug CONFIG+=qml_debug
} else { } else {

View File

@ -166,6 +166,11 @@ SOURCES += $$PWD/CameraImageWrapper.cpp \
$$PWD/zxing/zxing/BinaryBitmap.cpp \ $$PWD/zxing/zxing/BinaryBitmap.cpp \
$$PWD/zxing/zxing/Binarizer.cpp \ $$PWD/zxing/zxing/Binarizer.cpp \
$$PWD/zxing/zxing/BarcodeFormat.cpp \ $$PWD/zxing/zxing/BarcodeFormat.cpp \
$$PWD/zxing/zxing/ReaderException.cpp \
$$PWD/zxing/zxing/IllegalStateException.cpp \
$$PWD/zxing/zxing/NotFoundException.cpp \
$$PWD/zxing/zxing/UnsupportedEncodingException.cpp \
$$PWD/zxing/zxing/WriterException.cpp \
$$PWD/zxing/zxing/aztec/AztecReader.cpp \ $$PWD/zxing/zxing/aztec/AztecReader.cpp \
$$PWD/zxing/zxing/aztec/AztecDetectorResult.cpp \ $$PWD/zxing/zxing/aztec/AztecDetectorResult.cpp \
$$PWD/zxing/zxing/common/StringUtils.cpp \ $$PWD/zxing/zxing/common/StringUtils.cpp \

View File

@ -22,6 +22,7 @@ TARGET = QZXing
TEMPLATE = lib TEMPLATE = lib
# CONFIG += staticlib # CONFIG += staticlib
gcc:QMAKE_CXXFLAGS += -Wall -Wextra
DEFINES -= DISABLE_LIBRARY_FEATURES DEFINES -= DISABLE_LIBRARY_FEATURES
symbian { symbian {
@ -66,5 +67,3 @@ OTHER_FILES += \
qtc_packaging/debian_fremantle/control \ qtc_packaging/debian_fremantle/control \
qtc_packaging/debian_fremantle/compat \ qtc_packaging/debian_fremantle/compat \
qtc_packaging/debian_fremantle/changelog qtc_packaging/debian_fremantle/changelog

View File

@ -23,6 +23,6 @@
using zxing::ChecksumException; using zxing::ChecksumException;
ChecksumException::ChecksumException() throw() {} ChecksumException::ChecksumException() noexcept {}
ChecksumException::ChecksumException(const char *msg) throw() : ReaderException(msg) {} ChecksumException::ChecksumException(const char *msg) noexcept : ReaderException(msg) {}
ChecksumException::~ChecksumException() throw() {} ChecksumException::~ChecksumException() noexcept {}

View File

@ -23,11 +23,10 @@
namespace zxing { namespace zxing {
class ChecksumException : public ReaderException { class ChecksumException : public ReaderException {
typedef ReaderException Base;
public: public:
ChecksumException() throw(); ChecksumException() noexcept;
ChecksumException(const char *msg) throw(); ChecksumException(const char *msg) noexcept;
~ChecksumException() throw(); ~ChecksumException() noexcept;
}; };
} }

View File

@ -26,18 +26,41 @@
using zxing::Exception; using zxing::Exception;
Exception::Exception() noexcept
: message(nullptr) {
}
Exception::Exception(const char *msg) noexcept
: message(copy(msg)) {
}
Exception::Exception(const zxing::Exception &that) noexcept
: std::exception(that),
message(copy(that.message)) {
}
Exception::~Exception() noexcept {
if(message) {
deleteMessage();
}
}
const char *Exception::what() const noexcept {
return message ? message : "";
}
void Exception::deleteMessage() { void Exception::deleteMessage() {
delete [] message; delete [] message;
} }
char const* Exception::copy(char const* msg) { char const* Exception::copy(char const* msg) {
char* message = 0; char* message = nullptr;
if (msg) { if (msg) {
int l = strlen(msg)+1; auto l = strlen(msg)+1;
if (l) { if (l) {
message = new char[l]; message = new char[l];
strcpy(message, msg); strcpy(message, msg);
}
} }
} return message;
return message;
} }

View File

@ -31,15 +31,11 @@ private:
char const* const message; char const* const message;
public: public:
Exception() throw() : message(0) {} Exception() noexcept;
Exception(const char* msg) throw() : message(copy(msg)) {} Exception(const char* msg) noexcept;
Exception(Exception const& that) throw() : std::exception(that), message(copy(that.message)) {} Exception(Exception const& that) noexcept;
~Exception() throw() { ~Exception() noexcept;
if(message) { char const* what() const noexcept;
deleteMessage();
}
}
char const* what() const throw() {return message ? message : "";}
private: private:
static char const* copy(char const*); static char const* copy(char const*);

View File

@ -29,7 +29,7 @@ FormatException::FormatException(const char *msg) :
ReaderException(msg) { ReaderException(msg) {
} }
FormatException::~FormatException() throw() { FormatException::~FormatException() noexcept {
} }
FormatException const& FormatException const&

View File

@ -28,7 +28,7 @@ class FormatException : public ReaderException {
public: public:
FormatException(); FormatException();
FormatException(const char *msg); FormatException(const char *msg);
~FormatException() throw(); ~FormatException() noexcept;
static FormatException const& getFormatInstance(); static FormatException const& getFormatInstance();
}; };

View File

@ -0,0 +1,30 @@
/*
* IllegalStateException.cpp
* zxing
*
* Created by Alexander Stillich on 05/11/2018.
* Copyright 2008 ZXing authors All rights reserved.
*
* 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 <zxing/IllegalStateException.h>
zxing::IllegalStateException::IllegalStateException() noexcept {
}
zxing::IllegalStateException::IllegalStateException(const char *msg) noexcept
: ReaderException(msg) {
}
zxing::IllegalStateException::~IllegalStateException() noexcept {
}

View File

@ -25,9 +25,9 @@ namespace zxing {
class IllegalStateException : public ReaderException { class IllegalStateException : public ReaderException {
public: public:
IllegalStateException() throw() {} IllegalStateException() noexcept;
IllegalStateException(const char *msg) throw() : ReaderException(msg) {} IllegalStateException(const char *msg) noexcept;
~IllegalStateException() throw() {} ~IllegalStateException() noexcept;
}; };
} }

View File

@ -0,0 +1,30 @@
/*
* IllegalStateException.cpp
* zxing
*
* Created by Alexander Stillich on 05/11/2018.
* Copyright 2008 ZXing authors All rights reserved.
*
* 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 <zxing/NotFoundException.h>
zxing::NotFoundException::NotFoundException() noexcept {
}
zxing::NotFoundException::NotFoundException(const char *msg) noexcept
: ReaderException(msg) {
}
zxing::NotFoundException::~NotFoundException() noexcept {
}

View File

@ -25,9 +25,9 @@ namespace zxing {
class NotFoundException : public ReaderException { class NotFoundException : public ReaderException {
public: public:
NotFoundException() throw() {} NotFoundException() noexcept;
NotFoundException(const char *msg) throw() : ReaderException(msg) {} NotFoundException(const char *msg) noexcept;
~NotFoundException() throw() {} ~NotFoundException() noexcept;
}; };
} }

View File

@ -0,0 +1,30 @@
/*
* ReaderException.cpp
* zxing
*
* Created by Alexander Stillich on 05/11/2018.
* Copyright 2008 ZXing authors All rights reserved.
*
* 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 <zxing/ReaderException.h>
zxing::ReaderException::ReaderException() noexcept {
}
zxing::ReaderException::ReaderException(const char *msg) noexcept
: Exception(msg) {
}
zxing::ReaderException::~ReaderException() noexcept {
}

View File

@ -27,9 +27,9 @@ namespace zxing {
class ReaderException : public Exception { class ReaderException : public Exception {
public: public:
ReaderException() throw() {} ReaderException() noexcept;
ReaderException(char const* msg) throw() : Exception(msg) {} ReaderException(char const* msg) noexcept;
~ReaderException() throw() {} ~ReaderException() noexcept;
}; };
} }

View File

@ -0,0 +1,30 @@
/*
* UnsupportedEncodingException.cpp
* zxing
*
* Created by Alexander Stillich on 05/11/2018.
* Copyright 2008 ZXing authors All rights reserved.
*
* 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 <zxing/UnsupportedEncodingException.h>
zxing::UnsupportedEncodingException::UnsupportedEncodingException() noexcept {
}
zxing::UnsupportedEncodingException::UnsupportedEncodingException(const char *msg) noexcept
: Exception(msg) {
}
zxing::UnsupportedEncodingException::~UnsupportedEncodingException() noexcept {
}

View File

@ -7,9 +7,9 @@ namespace zxing {
class UnsupportedEncodingException : public Exception { class UnsupportedEncodingException : public Exception {
public: public:
UnsupportedEncodingException() throw() {} UnsupportedEncodingException() noexcept;
UnsupportedEncodingException(char const* msg) throw() : Exception(msg) {} UnsupportedEncodingException(char const* msg) noexcept;
~UnsupportedEncodingException() throw() {} ~UnsupportedEncodingException() noexcept;
}; };
} }

View File

@ -0,0 +1,30 @@
/*
* UnsupportedEncodingException.cpp
* zxing
*
* Created by Alexander Stillich on 05/11/2018.
* Copyright 2008 ZXing authors All rights reserved.
*
* 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 <zxing/WriterException.h>
zxing::WriterException::WriterException() noexcept {
}
zxing::WriterException::WriterException(const char *msg) noexcept
: Exception(msg) {
}
zxing::WriterException::~WriterException() noexcept {
}

View File

@ -7,9 +7,9 @@ namespace zxing {
class WriterException : public Exception { class WriterException : public Exception {
public: public:
WriterException() throw() {} WriterException() noexcept;
WriterException(char const* msg) throw() : Exception(msg) {} WriterException(char const* msg) noexcept;
~WriterException() throw() {} ~WriterException() noexcept;
}; };
} }

View File

@ -24,4 +24,4 @@ using zxing::IllegalArgumentException;
IllegalArgumentException::IllegalArgumentException() : Exception() {} IllegalArgumentException::IllegalArgumentException() : Exception() {}
IllegalArgumentException::IllegalArgumentException(const char *msg) : Exception(msg) {} IllegalArgumentException::IllegalArgumentException(const char *msg) : Exception(msg) {}
IllegalArgumentException::~IllegalArgumentException() throw() {} IllegalArgumentException::~IllegalArgumentException() noexcept {}

View File

@ -28,7 +28,7 @@ class IllegalArgumentException : public Exception {
public: public:
IllegalArgumentException(); IllegalArgumentException();
IllegalArgumentException(const char *msg); IllegalArgumentException(const char *msg);
~IllegalArgumentException() throw(); ~IllegalArgumentException() noexcept;
}; };
} }

View File

@ -21,10 +21,10 @@
#include <zxing/common/reedsolomon/ReedSolomonException.h> #include <zxing/common/reedsolomon/ReedSolomonException.h>
namespace zxing { namespace zxing {
ReedSolomonException::ReedSolomonException(const char *msg) throw() : ReedSolomonException::ReedSolomonException(const char *msg) noexcept :
Exception(msg) { Exception(msg) {
} }
ReedSolomonException::~ReedSolomonException() throw() { ReedSolomonException::~ReedSolomonException() noexcept {
} }
} }

View File

@ -25,8 +25,8 @@
namespace zxing { namespace zxing {
class ReedSolomonException : public Exception { class ReedSolomonException : public Exception {
public: public:
ReedSolomonException(const char *msg) throw(); ReedSolomonException(const char *msg) noexcept;
~ReedSolomonException() throw(); ~ReedSolomonException() noexcept;
}; };
} }

View File

@ -16,7 +16,7 @@ namespace datamatrix {
class DetectorException : public Exception { class DetectorException : public Exception {
public: public:
DetectorException(const char *msg); DetectorException(const char *msg);
virtual ~DetectorException() throw(); virtual ~DetectorException() noexcept;
}; };
} /* namespace nexxera */ } /* namespace nexxera */
} /* namespace zxing */ } /* namespace zxing */