Fix compiler warnings on macOS clang #21

Closed
Ghost wants to merge 0 commits from refs/pull/21/head into master
Ghost commented 2023-10-18 13:22:18 +02:00 (Migrated from bitcoincashcode.org)

Just some nits but here is what the compiler didn't like:

  • Apparently Qt's qAsConst is marked as deprecated (at least in Qt 6.6.0), so they recommend one uses std::as_const
  • Compiler feels happier with #ifdef rather than #if for TARGET_OS_Android in the not-defined case.

Here is a sample of the warnings generated before this commit:

/Users/calin/bitcoin/src/flowee/pay/src/FloweePay.cpp:220:5: warning: 'TARGET_OS_Android' is not defined, evaluates to 0 [-Wundef-prefix=TARGET_OS_]
#if TARGET_OS_Android
    ^
/Users/calin/bitcoin/src/flowee/pay/src/FloweePay.cpp:1049:31: warning: 'qAsConst<QList<Wallet *>>' is deprecated: Use std::as_const() instead. [-Wdeprecated-declarations]
    for (const auto *wallet : qAsConst(m_wallets)) {
                              ^
/Users/calin/Qt512/6.6.0/macos/lib/QtCore.framework/Headers/qttypetraits.h:32:1: note: 'qAsConst<QList<Wallet *>>' has been explicitly marked deprecated here
QT_DEPRECATED_VERSION_X_6_6("Use std::as_const() instead.")
^
/Users/calin/Qt512/6.6.0/macos/lib/QtCore.framework/Headers/qtdeprecationmarkers.h:175:44: note: expanded from macro 'QT_DEPRECATED_VERSION_X_6_6'
# define QT_DEPRECATED_VERSION_X_6_6(text) QT_DEPRECATED_X(text)
                                           ^
/Users/calin/Qt512/6.6.0/macos/lib/QtCore.framework/Headers/qtdeprecationmarkers.h:27:33: note: expanded from macro 'QT_DEPRECATED_X'
#  define QT_DEPRECATED_X(text) Q_DECL_DEPRECATED_X(text)
                                ^
/Users/calin/Qt512/6.6.0/macos/lib/QtCore.framework/Headers/qcompilerdetection.h:982:36: note: expanded from macro 'Q_DECL_DEPRECATED_X'
#  define Q_DECL_DEPRECATED_X(x) [[deprecated(x)]]
                                   ^
2 warnings generated.
/Users/calin/bitcoin/src/flowee/pay/src/CameraController.cpp:36:5: warning: 'TARGET_OS_Android' is not defined, evaluates to 0 [-Wundef-prefix=TARGET_OS_]
#if TARGET_OS_Android && QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
    ^
1 warning generated.
Just some nits but here is what the compiler didn't like: - Apparently Qt's `qAsConst` is marked as deprecated (at least in Qt 6.6.0), so they recommend one uses `std::as_const` - Compiler feels happier with `#ifdef` rather than `#if` for `TARGET_OS_Android` in the not-defined case. Here is a sample of the warnings generated before this commit: ``` /Users/calin/bitcoin/src/flowee/pay/src/FloweePay.cpp:220:5: warning: 'TARGET_OS_Android' is not defined, evaluates to 0 [-Wundef-prefix=TARGET_OS_] #if TARGET_OS_Android ^ /Users/calin/bitcoin/src/flowee/pay/src/FloweePay.cpp:1049:31: warning: 'qAsConst<QList<Wallet *>>' is deprecated: Use std::as_const() instead. [-Wdeprecated-declarations] for (const auto *wallet : qAsConst(m_wallets)) { ^ /Users/calin/Qt512/6.6.0/macos/lib/QtCore.framework/Headers/qttypetraits.h:32:1: note: 'qAsConst<QList<Wallet *>>' has been explicitly marked deprecated here QT_DEPRECATED_VERSION_X_6_6("Use std::as_const() instead.") ^ /Users/calin/Qt512/6.6.0/macos/lib/QtCore.framework/Headers/qtdeprecationmarkers.h:175:44: note: expanded from macro 'QT_DEPRECATED_VERSION_X_6_6' # define QT_DEPRECATED_VERSION_X_6_6(text) QT_DEPRECATED_X(text) ^ /Users/calin/Qt512/6.6.0/macos/lib/QtCore.framework/Headers/qtdeprecationmarkers.h:27:33: note: expanded from macro 'QT_DEPRECATED_X' # define QT_DEPRECATED_X(text) Q_DECL_DEPRECATED_X(text) ^ /Users/calin/Qt512/6.6.0/macos/lib/QtCore.framework/Headers/qcompilerdetection.h:982:36: note: expanded from macro 'Q_DECL_DEPRECATED_X' # define Q_DECL_DEPRECATED_X(x) [[deprecated(x)]] ^ 2 warnings generated. /Users/calin/bitcoin/src/flowee/pay/src/CameraController.cpp:36:5: warning: 'TARGET_OS_Android' is not defined, evaluates to 0 [-Wundef-prefix=TARGET_OS_] #if TARGET_OS_Android && QT_VERSION < QT_VERSION_CHECK(6, 5, 0) ^ 1 warning generated. ```
Ghost commented 2023-10-18 17:02:18 +02:00 (Migrated from bitcoincashcode.org)

Great catch for each of those!

Great catch for each of those!

Pull request closed

Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Flowee/pay#21