HomePhabricator

depends: Fix compile error for Qt when using newer GCC 11+

Description

depends: Fix compile error for Qt when using newer GCC 11+

Summary:

This patch fixes a compile error encountered on newer Ubuntu when building Qt 5.9.7. The issue was observed on Ubuntu 21.10 and 22.04, where a missing include caused compile errors.

This patch just fixes the error by including <limits>.

See BCHN issue #417

This is a backport of https://gitlab.com/bitcoin-cash-node/bitcoin-cash-node/-/merge_requests/1530

Note: the error fixed by this is also seen when compiling Qt 5.12.10 and Qt 5.12.11
It can be dropped with Qt 5.15.x

Test Plan:
On Ubuntu 22.04, run

cd depends
HOST=x86_64-linux-gnu make qt

Before this patch, it errors with this log:

In file included from /home/pierre/dev/bitcoin-abc/depends/work/build/x86_64-linux-gnu/qt/5.9.8-23c80104b59/qtbase/src/corelib/tools/qbytearray.cpp:42:
/home/pierre/dev/bitcoin-abc/depends/work/build/x86_64-linux-gnu/qt/5.9.8-23c80104b59/qtbase/src/corelib/tools/qbytearraymatcher.h: In static member function ‘static QStaticByteArrayMatcherBase::Skiptable QStaticByteArrayMatcherBase::generate(const char*, uint)’:
/home/pierre/dev/bitcoin-abc/depends/work/build/x86_64-linux-gnu/qt/5.9.8-23c80104b59/qtbase/src/corelib/tools/qbytearraymatcher.h:103:38: error: ‘numeric_limits’ is not a member of ‘std’
  103 |         const auto uchar_max = (std::numeric_limits<uchar>::max)();
      |                                      ^~~~~~~~~~~~~~
/home/pierre/dev/bitcoin-abc/depends/work/build/x86_64-linux-gnu/qt/5.9.8-23c80104b59/qtbase/src/corelib/tools/qbytearraymatcher.h:103:58: error: expected primary-expression before ‘>’ token
  103 |         const auto uchar_max = (std::numeric_limits<uchar>::max)();
      |                                                          ^
/home/pierre/dev/bitcoin-abc/depends/work/build/x86_64-linux-gnu/qt/5.9.8-23c80104b59/qtbase/src/corelib/tools/qbytearraymatcher.h:103:61: error: ‘::max’ has not been declared; did you mean ‘std::max’?
  103 |         const auto uchar_max = (std::numeric_limits<uchar>::max)();
      |                                                             ^~~
      |                                                             std::max
In file included from /usr/include/c++/11/algorithm:62,
...

After the patch, no error.

Run also gitian builds on CI

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D13722

Details

Provenance
CCulianuAuthored on Apr 12 2022, 00:46
PiRKCommitted on Apr 15 2023, 09:51
PiRKPushed on Apr 15 2023, 09:51
Reviewer
Restricted Project
Differential Revision
D13722: depends: Fix compile error for Qt when using newer GCC 11+
Parents
rABCcf87c2aeb876: [Cashtab] [Alias] - Accept aliases as eCash address in contact list
Branches
Unknown
Tags
Unknown