Fix error: literal operator suffixes not preceded by '_' are reserved for future standardization.

Old GCC versions do not allow to suppress the warning in certain cases. Switching to using macro.
This commit is contained in:
Roman Telezhynskyi 2022-09-08 19:10:00 +03:00
parent d32093bf4d
commit 3c1f5c04ca
7 changed files with 26 additions and 267 deletions

View file

@ -361,7 +361,7 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) :
break;
}
std::this_thread::sleep_for(100ms);
std::this_thread::sleep_for(MSECONDS(100));
}
}
@ -391,7 +391,7 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) :
if (m_cmd->IsGuiEnabled())
{
QTimer::singleShot(1s, this, &VPMainWindow::SetDefaultGUILanguage);
QTimer::singleShot(SECONDS(1), this, &VPMainWindow::SetDefaultGUILanguage);
}
}

View file

@ -245,7 +245,7 @@ TMainWindow::TMainWindow(QWidget *parent)
if (MApplication::VApp()->IsAppInGUIMode())
{
QTimer::singleShot(1s, this, &TMainWindow::SetDefaultGUILanguage);
QTimer::singleShot(SECONDS(1), this, &TMainWindow::SetDefaultGUILanguage);
}
}

View file

@ -88,7 +88,7 @@ DialogLayoutProgress::DialogLayoutProgress(QElapsedTimer timer, qint64 timeout,
m_progressTimer->stop();
}
});
m_progressTimer->start(1s);
m_progressTimer->start(SECONDS(1));
}
//---------------------------------------------------------------------------------------------------------------------

View file

@ -96,7 +96,7 @@ void VWidgetDetails::UpdateList()
// The filling table is a very expensive operation. This optimization will postpone it.
// Each time a new request happen we will wait 800 ms before calling it. If at this time a new request will arrive
// we will wait 800 ms more. And so on, until nothing happens within 800ms.
m_updateListTimer->start(800ms);
m_updateListTimer->start(MSECONDS(800));
}
//---------------------------------------------------------------------------------------------------------------------

View file

@ -474,7 +474,7 @@ MainWindow::MainWindow(QWidget *parent)
if (VApplication::IsGUIMode())
{
QTimer::singleShot(1s, this, &MainWindow::SetDefaultGUILanguage);
QTimer::singleShot(SECONDS(1), this, &MainWindow::SetDefaultGUILanguage);
}
}
@ -2139,7 +2139,7 @@ void MainWindow::MeasurementsChanged(const QString &path)
{
m_mChanges = true;
m_mChangesAsked = false;
m_measurementsSyncTimer->start(1500ms);
m_measurementsSyncTimer->start(MSECONDS(1500));
}
else
{
@ -2149,7 +2149,7 @@ void MainWindow::MeasurementsChanged(const QString &path)
{
m_mChanges = true;
m_mChangesAsked = false;
m_measurementsSyncTimer->start(1500ms);
m_measurementsSyncTimer->start(MSECONDS(1500));
break;
}

View file

@ -35,14 +35,6 @@
#include <chrono> // std::chrono::duration, std::chrono::system_clock, etc
#include <cstdint> // std::int32_t
#if __cplusplus < 201402L
#include <QtGlobal>
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#endif
BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE
namespace bpstd {
@ -90,93 +82,21 @@ namespace bpstd {
constexpr auto operator""_h(unsigned long long x) -> std::chrono::hours;
constexpr auto operator""_h(long double x) -> std::chrono::duration<double, std::ratio<3600,1>>;
#if __cplusplus < 201402L
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals")
QT_WARNING_DISABLE_GCC("-Wliteral-suffix")
// available only since C++14
constexpr auto operator""h(unsigned long long x) -> std::chrono::hours;
constexpr auto operator""h(long double x) -> std::chrono::duration<double, std::ratio<3600,1>>;
QT_WARNING_POP
#endif
constexpr auto operator""_min(unsigned long long x) -> chrono::minutes;
constexpr auto operator""_min(long double x) -> chrono::duration<double, std::ratio<60>>;
#if __cplusplus < 201402L
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals")
QT_WARNING_DISABLE_GCC("-Wliteral-suffix")
// available only since C++14
constexpr auto operator""min(unsigned long long x) -> chrono::minutes;
constexpr auto operator""min(long double x) -> chrono::duration<double, std::ratio<60>>;
QT_WARNING_POP
#endif
constexpr auto operator""_s(unsigned long long x) -> chrono::seconds;
constexpr auto operator""_s(long double x) -> chrono::duration<double>;
#if __cplusplus < 201402L
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals")
QT_WARNING_DISABLE_GCC("-Wliteral-suffix")
// available only since C++14
constexpr auto operator""s(unsigned long long x) -> chrono::seconds;
constexpr auto operator""s(long double x) -> chrono::duration<double>;
QT_WARNING_POP
#endif
constexpr auto operator""_ms(unsigned long long x) -> chrono::milliseconds;
constexpr auto operator""_ms(long double x) -> chrono::duration<double, std::milli>;
#if __cplusplus < 201402L
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals")
QT_WARNING_DISABLE_GCC("-Wliteral-suffix")
// available only since C++14
constexpr auto operator""ms(unsigned long long x) -> chrono::milliseconds;
constexpr auto operator""ms(long double x) -> chrono::duration<double, std::milli>;
QT_WARNING_POP
#endif
constexpr auto operator""_us(unsigned long long x) -> chrono::microseconds;
constexpr auto operator""_us(long double x) -> chrono::duration<double, std::micro>;
#if __cplusplus < 201402L
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals")
QT_WARNING_DISABLE_GCC("-Wliteral-suffix")
// available only since C++14
constexpr auto operator""us(unsigned long long x) -> chrono::microseconds;
constexpr auto operator""us(long double x) -> chrono::duration<double, std::micro>;
QT_WARNING_POP
#endif
constexpr auto operator""_ns(unsigned long long x) -> chrono::nanoseconds;
constexpr auto operator""_ns(long double x) -> chrono::duration<double, std::nano>;
#if __cplusplus < 201402L
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals")
QT_WARNING_DISABLE_GCC("-Wliteral-suffix")
// available only since C++14
constexpr auto operator""ns(unsigned long long x) -> chrono::nanoseconds;
constexpr auto operator""ns(long double x) -> chrono::duration<double, std::nano>;
QT_WARNING_POP
#endif
} // namespace chrono_literals
} // namespace literals
} // namespace bpstd
@ -188,251 +108,72 @@ auto
return chrono::hours{x};
}
#if __cplusplus < 201402L
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals")
QT_WARNING_DISABLE_GCC("-Wliteral-suffix")
inline BPSTD_INLINE_VISIBILITY constexpr
auto bpstd::literals::chrono_literals::operator""h(unsigned long long x) -> std::chrono::hours
{
return chrono::hours{x};
}
QT_WARNING_POP
#endif
inline BPSTD_INLINE_VISIBILITY constexpr
auto bpstd::literals::chrono_literals::operator""_h(long double x) -> std::chrono::duration<double, std::ratio<3600,1>>
{
return chrono::duration<double, std::ratio<3600,1>>{x};
}
#if __cplusplus < 201402L
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals")
QT_WARNING_DISABLE_GCC("-Wliteral-suffix")
// available only since C++14
inline BPSTD_INLINE_VISIBILITY constexpr
auto bpstd::literals::chrono_literals::operator""h(long double x) -> std::chrono::duration<double, std::ratio<3600,1>>
{
return chrono::duration<double, std::ratio<3600,1>>{x};
}
QT_WARNING_POP
#endif
inline BPSTD_INLINE_VISIBILITY constexpr
auto bpstd::literals::chrono_literals::operator""_min(unsigned long long x) -> bpstd::chrono::minutes
{
return chrono::minutes{x};
}
#if __cplusplus < 201402L
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals")
QT_WARNING_DISABLE_GCC("-Wliteral-suffix")
// available only since C++14
inline BPSTD_INLINE_VISIBILITY constexpr
auto bpstd::literals::chrono_literals::operator""min(unsigned long long x) -> bpstd::chrono::minutes
{
return chrono::minutes{x};
}
QT_WARNING_POP
#endif
inline BPSTD_INLINE_VISIBILITY constexpr
auto bpstd::literals::chrono_literals::operator""_min(long double x) -> bpstd::chrono::duration<double, std::ratio<60>>
{
return chrono::duration<double, std::ratio<60>>{x};
}
#if __cplusplus < 201402L
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals")
QT_WARNING_DISABLE_GCC("-Wliteral-suffix")
// available only since C++14
inline BPSTD_INLINE_VISIBILITY constexpr
auto bpstd::literals::chrono_literals::operator""min(long double x) -> bpstd::chrono::duration<double, std::ratio<60>>
{
return chrono::duration<double, std::ratio<60>>{x};
}
QT_WARNING_POP
#endif
inline BPSTD_INLINE_VISIBILITY constexpr
auto bpstd::literals::chrono_literals::operator""_s(unsigned long long x) -> bpstd::chrono::seconds
{
return chrono::seconds{x};
}
#if __cplusplus < 201402L
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals")
QT_WARNING_DISABLE_GCC("-Wliteral-suffix")
// available only since C++14
inline BPSTD_INLINE_VISIBILITY constexpr
auto bpstd::literals::chrono_literals::operator""s(unsigned long long x) -> bpstd::chrono::seconds
{
return chrono::seconds{x};
}
QT_WARNING_POP
#endif
inline BPSTD_INLINE_VISIBILITY constexpr
auto bpstd::literals::chrono_literals::operator""_s(long double x) -> bpstd::chrono::duration<double>
{
return chrono::duration<double>{x};
}
#if __cplusplus < 201402L
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals")
QT_WARNING_DISABLE_GCC("-Wliteral-suffix")
// available only since C++14
inline BPSTD_INLINE_VISIBILITY constexpr
auto bpstd::literals::chrono_literals::operator""s(long double x) -> bpstd::chrono::duration<double>
{
return chrono::duration<double>{x};
}
QT_WARNING_POP
#endif
inline BPSTD_INLINE_VISIBILITY constexpr
auto bpstd::literals::chrono_literals::operator""_ms(unsigned long long x) -> bpstd::chrono::milliseconds
{
return chrono::milliseconds{x};
}
#if __cplusplus < 201402L
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals")
QT_WARNING_DISABLE_GCC("-Wliteral-suffix")
// available only since C++14
inline BPSTD_INLINE_VISIBILITY constexpr
auto bpstd::literals::chrono_literals::operator""ms(unsigned long long x) -> bpstd::chrono::milliseconds
{
return chrono::milliseconds{x};
}
QT_WARNING_POP
#endif
inline BPSTD_INLINE_VISIBILITY constexpr
auto bpstd::literals::chrono_literals::operator""_ms(long double x) -> bpstd::chrono::duration<double, std::milli>
{
return chrono::duration<double, std::milli>{x};
}
#if __cplusplus < 201402L
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals")
QT_WARNING_DISABLE_GCC("-Wliteral-suffix")
// available only since C++14
inline BPSTD_INLINE_VISIBILITY constexpr
auto bpstd::literals::chrono_literals::operator""ms(long double x) -> bpstd::chrono::duration<double, std::milli>
{
return chrono::duration<double, std::milli>{x};
}
QT_WARNING_POP
#endif
inline BPSTD_INLINE_VISIBILITY constexpr
auto bpstd::literals::chrono_literals::operator ""_us(unsigned long long x) -> bpstd::chrono::microseconds
{
return chrono::microseconds{x};
}
#if __cplusplus < 201402L
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals")
QT_WARNING_DISABLE_GCC("-Wliteral-suffix")
// available only since C++14
inline BPSTD_INLINE_VISIBILITY constexpr
auto bpstd::literals::chrono_literals::operator ""us(unsigned long long x) -> bpstd::chrono::microseconds
{
return chrono::microseconds{x};
}
QT_WARNING_POP
#endif
inline BPSTD_INLINE_VISIBILITY constexpr
auto bpstd::literals::chrono_literals::operator""_us(long double x) -> bpstd::chrono::duration<double, std::micro>
{
return chrono::duration<double, std::micro>{x};
}
#if __cplusplus < 201402L
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals")
QT_WARNING_DISABLE_GCC("-Wliteral-suffix")
// available only since C++14
inline BPSTD_INLINE_VISIBILITY constexpr
auto bpstd::literals::chrono_literals::operator""us(long double x) -> bpstd::chrono::duration<double, std::micro>
{
return chrono::duration<double, std::micro>{x};
}
QT_WARNING_POP
#endif
inline BPSTD_INLINE_VISIBILITY constexpr
auto bpstd::literals::chrono_literals::operator""_ns(unsigned long long x) -> bpstd::chrono::nanoseconds
{
return chrono::nanoseconds{x};
}
#if __cplusplus < 201402L
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals")
QT_WARNING_DISABLE_GCC("-Wliteral-suffix")
// available only since C++14
inline BPSTD_INLINE_VISIBILITY constexpr
auto bpstd::literals::chrono_literals::operator""ns(unsigned long long x) -> bpstd::chrono::nanoseconds
{
return chrono::nanoseconds{x};
}
QT_WARNING_POP
#endif
inline BPSTD_INLINE_VISIBILITY constexpr
auto bpstd::literals::chrono_literals::operator""_ns(long double x) -> bpstd::chrono::duration<double, std::nano>
{
return chrono::duration<double, std::nano>{x};
}
#if __cplusplus < 201402L
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wuser-defined-literals")
QT_WARNING_DISABLE_GCC("-Wliteral-suffix")
// available only since C++14
inline BPSTD_INLINE_VISIBILITY constexpr
auto bpstd::literals::chrono_literals::operator""ns(long double x) -> bpstd::chrono::duration<double, std::nano>
{
return chrono::duration<double, std::nano>{x};
}
QT_WARNING_POP
#endif
BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE
#endif /* BPSTD_CHRONO_HPP */

View file

@ -55,4 +55,22 @@ void qAsConst(const T &&) Q_DECL_EQ_DELETE;
Q_DISABLE_MOVE(Class)
#endif
#define SUFFIX_APPEND(x, y) x ## y // NOLINT(cppcoreguidelines-macro-usage)
#if __cplusplus >= 201402L
#define HOURS(x) SUFFIX_APPEND(x, h) // NOLINT(cppcoreguidelines-macro-usage)
#define MINUTES(x) SUFFIX_APPEND(x, min) // NOLINT(cppcoreguidelines-macro-usage)
#define SECONDS(x) SUFFIX_APPEND(x, s) // NOLINT(cppcoreguidelines-macro-usage)
#define MSECONDS(x) SUFFIX_APPEND(x, ms) // NOLINT(cppcoreguidelines-macro-usage)
#define MICSECONDS(x) SUFFIX_APPEND(x, us) // NOLINT(cppcoreguidelines-macro-usage)
#define NANOSECONDS(x) SUFFIX_APPEND(x, ns) // NOLINT(cppcoreguidelines-macro-usage)
#else
#define HOURS(x) SUFFIX_APPEND(x, _h) // NOLINT(cppcoreguidelines-macro-usage)
#define MINUTES(x) SUFFIX_APPEND(x, _min) // NOLINT(cppcoreguidelines-macro-usage)
#define SECONDS(x) SUFFIX_APPEND(x, _s) // NOLINT(cppcoreguidelines-macro-usage)
#define MSECONDS(x) SUFFIX_APPEND(x, _ms) // NOLINT(cppcoreguidelines-macro-usage)
#define MICSECONDS(x) SUFFIX_APPEND(x, _us) // NOLINT(cppcoreguidelines-macro-usage)
#define NANOSECONDS(x) SUFFIX_APPEND(x, _ns) // NOLINT(cppcoreguidelines-macro-usage)
#endif // __cplusplus >= 201402L
#endif // DEFGLOBAL_H