Skip to content

Commit 84ac6fb

Browse files
Fix the visibility compilation error for GCC <= 7 (apache#312)
### Motivation apache#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 capture>' [-Werror=attributes] 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.
1 parent 2e2f90b commit 84ac6fb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/RetryableOperation.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,12 @@ class RetryableOperation : public std::enable_shared_from_this<RetryableOperatio
7979
std::atomic_bool started_{false};
8080
DeadlineTimerPtr timer_;
8181

82-
Future<Result, T> runImpl(TimeDuration remainingTime) {
82+
// Fix the "declared with greater visibility" error for GCC <= 7
83+
#ifdef __GNUC__
84+
__attribute__((visibility("hidden")))
85+
#endif
86+
Future<Result, T>
87+
runImpl(TimeDuration remainingTime) {
8388
std::weak_ptr<RetryableOperation<T>> weakSelf{this->shared_from_this()};
8489
func_().addListener([this, weakSelf, remainingTime](Result result, const T& value) {
8590
auto self = weakSelf.lock();

0 commit comments

Comments
 (0)