PROTON-1635: [C++ binding] Building with gcc 4.4.7 Gcc 4.4.7 is not a full C++11 compiler, but does have some features - in particular threads and mutex.
The following fixes were needed: - new-style C++ loops - lack of std::thread move ctor - lack of copy ctor on proton::03::work - deprecated attribute can't have a message Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/c7f593e5 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/c7f593e5 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/c7f593e5 Branch: refs/heads/go1 Commit: c7f593e5774309e0d62caf647dda977eb0c6417c Parents: 2e9412c Author: Andrew Stitcher <astitc...@apache.org> Authored: Tue Oct 17 16:43:04 2017 -0400 Committer: Andrew Stitcher <astitc...@apache.org> Committed: Tue Oct 17 16:43:04 2017 -0400 ---------------------------------------------------------------------- .../bindings/cpp/include/proton/internal/export.hpp | 2 ++ proton-c/bindings/cpp/include/proton/work_queue.hpp | 10 +++++++++- proton-c/bindings/cpp/src/proactor_container_impl.cpp | 12 +++++++----- 3 files changed, 18 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7f593e5/proton-c/bindings/cpp/include/proton/internal/export.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/internal/export.hpp b/proton-c/bindings/cpp/include/proton/internal/export.hpp index 6101b58..d7a365d 100644 --- a/proton-c/bindings/cpp/include/proton/internal/export.hpp +++ b/proton-c/bindings/cpp/include/proton/internal/export.hpp @@ -64,6 +64,8 @@ # define PN_CPP_DEPRECATED(message) [[deprecated(message)]] # elif defined(WIN32) # define PN_CPP_DEPRECATED(message) __declspec(deprecated(message)) +# elif (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40500 +# define PN_CPP_DEPRECATED(message) __attribute__((deprecated)) # else # define PN_CPP_DEPRECATED(message) __attribute__((deprecated(message))) # endif http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7f593e5/proton-c/bindings/cpp/include/proton/work_queue.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/work_queue.hpp b/proton-c/bindings/cpp/include/proton/work_queue.hpp index 8d5e6ce..c1c105e 100644 --- a/proton-c/bindings/cpp/include/proton/work_queue.hpp +++ b/proton-c/bindings/cpp/include/proton/work_queue.hpp @@ -67,7 +67,15 @@ struct invocable_cloner : invocable { struct invocable_wrapper { invocable_wrapper(): wrapped_(0) {} invocable_wrapper(const invocable_wrapper& w): wrapped_(&w.wrapped_->clone()) {} - invocable_wrapper& operator=(invocable_wrapper& that) {std::swap(wrapped_, that.wrapped_); return *this; } + invocable_wrapper& operator=(const invocable_wrapper& that) { + invocable_wrapper newthis(that); + std::swap(wrapped_, newthis.wrapped_); + return *this; + } +#if PN_CPP_HAS_RVALUE_REFERENCES + invocable_wrapper(invocable_wrapper&& w): wrapped_(w.wrapped_) {} + invocable_wrapper& operator=(invocable_wrapper&& that) {delete wrapped_; wrapped_ = that.wrapped_; return *this; } +#endif ~invocable_wrapper() { delete wrapped_; } invocable_wrapper(const invocable& i): wrapped_(&i.clone()) {} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c7f593e5/proton-c/bindings/cpp/src/proactor_container_impl.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/proactor_container_impl.cpp b/proton-c/bindings/cpp/src/proactor_container_impl.cpp index f59cb9b..0965391 100644 --- a/proton-c/bindings/cpp/src/proactor_container_impl.cpp +++ b/proton-c/bindings/cpp/src/proactor_container_impl.cpp @@ -666,16 +666,18 @@ void container::impl::run(int threads) { #if PN_CPP_SUPPORTS_THREADS // Run handler threads - std::vector<std::thread> ts(threads-1); - if (threads>1) { - for (auto& t : ts) t = std::thread(&impl::thread, this); + typedef std::vector<std::thread*> vt; // pointer vector to work around failures in older compilers + vt ts(threads-1); + for (vt::iterator i = ts.begin(); i != ts.end(); ++i) { + *i = new std::thread(&impl::thread, this); } thread(); // Use this thread too. // Wait for the other threads to stop - if (threads>1) { - for (auto& t : ts) t.join(); + for (vt::iterator i = ts.begin(); i != ts.end(); ++i) { + (*i)->join(); + delete *i; } #else // Run a single handler thread (As we have no threading API) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org