diff --git a/CMakeLists.txt b/CMakeLists.txt index 16bb2b3..1f6ab07 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,7 @@ set(CMAKE_CXX_EXTENSIONS OFF) include(GNUInstallDirs) if(WIN32) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) set(LIBS_SYSTEM ws2_32) elseif(UNIX) set(LIBS_SYSTEM c stdc++) diff --git a/buildtst.sh b/buildtst.sh index c51171d..468a6d7 100755 --- a/buildtst.sh +++ b/buildtst.sh @@ -37,9 +37,9 @@ for COMPILER in $COMPILERS; do exit 1 fi - printf "Running unit tests:\n" + printf "Running unit tests for %s:\n" "${COMPILER}" if ! ./test/unit/paho-mqttpp-test ; then - printf "\nUnit test failed for %s\n" "${COMPILER}" + printf "\nUnit test failed for %s\n" "${COMPILER}" exit 3 fi diff --git a/src/message.cpp b/src/message.cpp index 15d1046..cc48524 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -30,9 +30,6 @@ constexpr bool message::DFLT_RETAINED; const MQTTAsync_message message::DFLT_C_STRUCT = MQTTAsync_message_initializer; -const string message::EMPTY_STR; -const binary message::EMPTY_BIN; - // -------------------------------------------------------------------------- message::message() : msg_(DFLT_C_STRUCT) diff --git a/src/mqtt/message.h b/src/mqtt/message.h index 1c911c8..feb3b97 100644 --- a/src/mqtt/message.h +++ b/src/mqtt/message.h @@ -61,11 +61,6 @@ private: /** Initializer for the C struct (from the C library) */ static const MQTTAsync_message DFLT_C_STRUCT; - /** An instance of an empty string (for performance) */ - static const string EMPTY_STR; - /** An instance of an empty binary (for performance) */ - static const binary EMPTY_BIN; - /** The underlying C message struct */ MQTTAsync_message msg_; /** The topic that the message was (or should be) sent on. */ @@ -236,6 +231,7 @@ public: * @return The topic string for the message. */ const string& get_topic() const { + static const string EMPTY_STR; return topic_ ? topic_.str() : EMPTY_STR; } /** @@ -249,13 +245,15 @@ public: /** * Gets the payload */ - const binary& get_payload() const { + const binary& get_payload() const { + static const binary EMPTY_BIN; return payload_ ? payload_.str() : EMPTY_BIN; } /** * Gets the payload as a string */ - const string& get_payload_str() const { + const string& get_payload_str() const { + static const string EMPTY_STR; return payload_ ? payload_.str() : EMPTY_STR; } /**