Skip to content

Commit

Permalink
Fix the visibility compilation error for GCC <= 7
Browse files Browse the repository at this point in the history
### Motivation

#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.
  • Loading branch information
BewareMyPower committed Sep 8, 2023
1 parent 2e2f90b commit bd1e85e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/RetryableOperation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit bd1e85e

Please sign in to comment.