Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt6 issue with sdrbase/util/baudot.cpp #1713

Closed
gvanem opened this issue Jun 12, 2023 · 3 comments
Closed

Qt6 issue with sdrbase/util/baudot.cpp #1713

gvanem opened this issue Jun 12, 2023 · 3 comments
Milestone

Comments

@gvanem
Copy link

gvanem commented Jun 12, 2023

While compiling sdrbase/util/baudot.cpp using Qt 6.2.4, I'm getting this compile error from clang-cl (ver 16.0.0):

util/baudot.cpp(182,51): error: use of overloaded operator '==' is ambiguous (with operand types 'QString' and 'char')
    if ((m_characterSet == Baudot::RUSSIAN) && (c == '\0'))
                                                ~ ^  ~~~~
f:\gv\Qt\6.2.4\msvc2019_64\include\QtCore/qstring.h(902,17): note: candidate function
    friend bool operator==(const QString &s1, std::nullptr_t) noexcept { return s1.isEmpty(); }
                ^
f:\gv\Qt\6.2.4\msvc2019_64\include\QtCore/qstring.h(915,17): note: candidate function
    friend bool operator==(const QString &s1, const char16_t *s2) noexcept { return s1 == QStringView(s2); }
                ^
f:\gv\Qt\6.2.4\msvc2019_64\include\QtCore/qstring.h(1356,22): note: candidate function
inline bool QString::operator==(const char *s) const
                     ^
1 error generated.

Similar from cl.

I'm not sure why, but I tried this patch in the hope it's logically similar:

--- a/sdrbase/util/baudot.cpp 2023-03-10 18:07:15
+++ b/sdrbase/util/baudot.cpp 2023-06-12 07:27:35
@@ -165,6 +165,7 @@
 QString BaudotDecoder::decode(char bits)
 {
     QString c = m_figure ? m_figures[(int)bits] : m_letters[(int)bits];
+    QString c_null = "\0";

     if ((c == '>') || (m_unshiftOnSpace && (c == " ")))
     {
@@ -179,7 +180,7 @@
         // Switch to figures
         m_figure = true;
     }
-    if ((m_characterSet == Baudot::RUSSIAN) && (c == '\0'))
+    if ((m_characterSet == Baudot::RUSSIAN) && (c == c_null))
     {
         // Switch to Cyrillic
         m_figure = false;

With this it compiles with both Qt 5 and 6. But I'm not sure what the test should do.

@gvanem
Copy link
Author

gvanem commented Jun 12, 2023

PS. Same issue in plugins/channelrx/demodrtty/rttydemodsink.cpp:

rttydemodsink.cpp(520,20): error: use of overloaded operator '!=' is ambiguous (with operand types 'QString' and 'char')
            if ((c != '\0') && (c != '<') && (c != '>') && (c != '^'))
                 ~ ^  ~~~~
f:\gv\Qt\6.2.4\msvc2019_64\include\QtCore/qstring.h(903,17): note: candidate function
    friend bool operator!=(const QString &s1, std::nullptr_t) noexcept { return !s1.isEmpty(); }
                ^
f:\gv\Qt\6.2.4\msvc2019_64\include\QtCore/qstring.h(916,17): note: candidate function
    friend bool operator!=(const QString &s1, const char16_t *s2) noexcept { return s1 != QStringView(s2); }
                ^
f:\gv\Qt\6.2.4\msvc2019_64\include\QtCore/qstring.h(1358,22): note: candidate function
inline bool QString::operator!=(const char *s) const
                     ^
1 error generated.

@f4exb
Copy link
Owner

f4exb commented Jun 12, 2023

I can understand the compiler may get confused. If I am not mistaken "c" is just a single character. What happens if we use a QChar instead of a QString?

@srcejon
Copy link
Collaborator

srcejon commented Jun 12, 2023

c can be a string in some of the more obscure character sets (for representing fractions). Comparing against "\0" is fin

But I would say stick to Qt 5 on Windows, and if you must use 6, don't use Qt 6.2 - use 6.4 (It will be worse than 5 whatever version of 6 you use - for now).

srcejon added a commit to srcejon/sdrangel that referenced this issue Jun 23, 2023
@srcejon srcejon closed this as completed Jun 30, 2023
@f4exb f4exb added this to the v7.15.1 milestone Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants