This is an automated email from the ASF dual-hosted git repository.

xyz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pulsar-client-cpp.git


The following commit(s) were added to refs/heads/main by this push:
     new 84ac6fb  Fix the visibility compilation error for GCC <= 7 (#312)
84ac6fb is described below

commit 84ac6fb912925a1c328ef06da2cc1f96803f15bc
Author: Yunze Xu <[email protected]>
AuthorDate: Sat Sep 9 13:28:18 2023 +0800

    Fix the visibility compilation error for GCC <= 7 (#312)
    
    ### Motivation
    
    https://github.com/apache/pulsar-client-cpp/pull/296 introduced a
    regression for GCC <= 7.
    
    > lib/RetryableOperation.h:109:66: error: 
'pulsar::RetryableOperation<T>::runImpl(pulsar::TimeDuration)::<lambda(pulsar::Result,
 const T&)> [with T = pulsar::LookupService::LookupResult]::<lambda(const 
boost::system::error_code&)>' declared with greater visibility than the type of 
its field 
'pulsar::RetryableOperation<T>::runImpl(pulsar::TimeDuration)::<lambda(pulsar::Result,
 const T&)> [with T = pulsar::LookupService::LookupResult]::<lambda(const 
boost::system::error_code&)>::<this c [...]
    
    It seems to be a bug for GCC <= 7 abort the visibility of the lambda
    expression might not be affected by the `-fvisibility=hidden` option.
    
    ### Modifications
    
    Add `__attribute__((visibility("hidden")))` to
    `RetryableOperation::runImpl` explicitly.
---
 lib/RetryableOperation.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/RetryableOperation.h b/lib/RetryableOperation.h
index 8a7b471..8bebb5b 100644
--- a/lib/RetryableOperation.h
+++ b/lib/RetryableOperation.h
@@ -79,7 +79,12 @@ class RetryableOperation : public 
std::enable_shared_from_this<RetryableOperatio
     std::atomic_bool started_{false};
     DeadlineTimerPtr timer_;
 
-    Future<Result, T> runImpl(TimeDuration remainingTime) {
+    // Fix the "declared with greater visibility" error for GCC <= 7
+#ifdef __GNUC__
+    __attribute__((visibility("hidden")))
+#endif
+    Future<Result, T>
+    runImpl(TimeDuration remainingTime) {
         std::weak_ptr<RetryableOperation<T>> 
weakSelf{this->shared_from_this()};
         func_().addListener([this, weakSelf, remainingTime](Result result, 
const T& value) {
             auto self = weakSelf.lock();

Reply via email to