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

Fix compilation errors when building with Qt 6.2.3 #1

Open
wants to merge 2 commits into
base: 6.2.3
Choose a base branch
from

Conversation

caarmen
Copy link

@caarmen caarmen commented Feb 13, 2022

Greetings!

I'm currently building qtspeech, on a system which has Qt 6.2.3, which I believe is the latest stable version as of when I'm opening this PR.

There are a couple of compilation errors.

Here are some suggested fixes.

I'm creating this PR based on the 6.2.3 branch, as that's the version of Qt that I'm using to build. I had more errors building the dev branch, which I won't get into here (some errors about plugin classes). I don't know which version of Qt is required to build the dev branch.

One error appears on all the platforms I tested (mac, linux, windows), and one is just on windows.


1️⃣ First error:

Fix compilation error casting QString to QLocale.

When building qtspeech against Qt 6.2.3, we see the below compilation error.

qtexttospeech_osx.mm:192:12: error: no viable conversion from returned value of type 'QString' to function return type 'QLocale'
    return QString::fromNSString(attrs[NSVoiceLocaleIdentifier]);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/jdoe/dev/Qt/6.2.3/macos/lib/QtCore.framework/Headers/qlocale.h:930:5: note: candidate constructor not viable: no known conversion from 'QString' to 'QLocale::Language' for 1st argument
    QLocale(Language language, Script script = AnyScript, Territory territory = AnyTerritory);
    ^   
/Users/jdoe/dev/Qt/6.2.3/macos/lib/QtCore.framework/Headers/qlocale.h:931:5: note: candidate constructor not viable: no known conversion from 'QString' to 'const QLocale &' for 1st argument
    QLocale(const QLocale &other);
    ^   
/Users/jdoe/dev/Qt/6.2.3/macos/lib/QtCore.framework/Headers/qlocale.h:1129:5: note: candidate constructor not viable: no known conversion from 'QString' to 'QLocalePrivate &' for 1st argument
    QLocale(QLocalePrivate &dd);
    ^   
/Users/jdoe/dev/Qt/6.2.3/macos/lib/QtCore.framework/Headers/qlocale.h:928:14: note: explicit constructor is not a candidate
    explicit QLocale(const QString &name);
             ^   
1 error generated.

To prevent this error, use the QLocale(QString) constructor.


2️⃣ Second error:

When building qtspeech against Qt 6.2.3, mingw_64, we see the below compilation error.

In file included from C:/Qt/Tools/mingw900_64/x86_64-w64-mingw32/include/windows.h:72,
                 from C:/Qt/6.2.3/mingw_64/include/QtCore/qt_windows.h:64,
                 from qtexttospeech_sapi.h:40,
                 from qtexttospeech_sapi.cpp:37:
C:/Qt/Tools/mingw900_64/x86_64-w64-mingw32/include/winuser.h:2965:43: error: variable 'CreateSyntheticPointerDevice' definition is marked dllimport
 2965 | WINUSERAPI HSYNTHETICPOINTERDEVICE WINAPI CreateSyntheticPointerDevice(POINTER_INPUT_TYPE pointerType, ULONG maxCount, POINTER_FEEDBACK_MODE mode);
      |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/Qt/Tools/mingw900_64/x86_64-w64-mingw32/include/winuser.h:2965:72: error: 'POINTER_INPUT_TYPE' was not declared in this scope; did you mean 'PRINTER_FONTTYPE'?
 2965 | WINUSERAPI HSYNTHETICPOINTERDEVICE WINAPI CreateSyntheticPointerDevice(POINTER_INPUT_TYP
 pointerType, ULONG maxCount, POINTER_FEEDBACK_MODE mode);
      |                                                                        ^~~~~~~~~~~~~~~~~
      |                                                                        PRINTER_FONTTYPE
C:/Qt/Tools/mingw900_64/x86_64-w64-mingw32/include/winuser.h:2965:110: error: expected primary-expression before 'maxCount'
 2965 | WINUSERAPI HSYNTHETICPOINTERDEVICE WINAPI CreateSyntheticPointerDevice(POINTER_INPUT_TYPE pointerType, ULONG maxCount, POINTER_FEEDBACK_MODE mode);
      |                                                                                                              ^~~~~~~~
C:/Qt/Tools/mingw900_64/x86_64-w64-mingw32/include/winuser.h:2965:120: error: 'POINTER_FEEDBACK_MODE' was not declared in this scope
 2965 | WINUSERAPI HSYNTHETICPOINTERDEVICE WINAPI CreateSyntheticPointerDevice(POINTER_INPUT_TYPE pointerType, ULONG maxCount, POINTER_FEEDBACK_MODE mode);
      |                                                                                                                        ^~~~~~~~~~~~~~~~~~~~~
C:/Qt/Tools/mingw900_64/x86_64-w64-mingw32/include/winuser.h:2965:146: error: expression list treated as compound expression in initializer [-fpermissive]
 2965 | WINUSERAPI HSYNTHETICPOINTERDEVICE WINAPI CreateSyntheticPointerDevice(POINTER_INPUT_TYPE pointerType, ULONG maxCount, POINTER_FEEDBACK_MODE mode);
      |                                                                                                                                                  ^
C:/Qt/Tools/mingw900_64/x86_64-w64-mingw32/include/winuser.h:2966:93: error: 'POINTER_TYPE_INFO' does not name a type; did you mean 'POINTER_64_INT'?
 2966 | WINUSERAPI WINBOOL WINAPI InjectSyntheticPointerInput(HSYNTHETICPOINTERDEVICE device, CONST POINTER_TYPE_INFO* pointerInfo, UINT32 count);
      |                                                                                             ^~~~~~~~~~~~~~~~~
      |                                                                                             POINTER_64_INT

Based on a tip mentioned in a related issue QTEXT-14, workaround this by including windows.h, before including qt_windows.h.

☝️ Note that src/plugins/tts/winrt/qtexttospeech_winrt.h also includes qt_windows.h. I didn't see any compilation errors for that, but I think the winrt project wasn't compiled at all on my machine.

When building qtspeech against Qt 6.2.3, we see the below compilation error.

```
qtexttospeech_osx.mm:192:12: error: no viable conversion from returned value of type 'QString' to function return type 'QLocale'
    return QString::fromNSString(attrs[NSVoiceLocaleIdentifier]);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/jdoe/dev/Qt/6.2.3/macos/lib/QtCore.framework/Headers/qlocale.h:930:5: note: candidate constructor not viable: no known conversion from 'QString' to 'QLocale::Language' for 1st argument
    QLocale(Language language, Script script = AnyScript, Territory territory = AnyTerritory);
    ^
/Users/jdoe/dev/Qt/6.2.3/macos/lib/QtCore.framework/Headers/qlocale.h:931:5: note: candidate constructor not viable: no known conversion from 'QString' to 'const QLocale &' for 1st argument
    QLocale(const QLocale &other);
    ^
/Users/jdoe/dev/Qt/6.2.3/macos/lib/QtCore.framework/Headers/qlocale.h:1129:5: note: candidate constructor not viable: no known conversion from 'QString' to 'QLocalePrivate &' for 1st argument
    QLocale(QLocalePrivate &dd);
    ^
/Users/jdoe/dev/Qt/6.2.3/macos/lib/QtCore.framework/Headers/qlocale.h:928:14: note: explicit constructor is not a candidate
    explicit QLocale(const QString &name);
             ^
1 error generated.
```

To prevent this error, use the `QLocale(QString)` constructor.
When building qtspeech against Qt 6.2.3, mingw_64, we see the below compilation error.

```
In file included from C:/Qt/Tools/mingw900_64/x86_64-w64-mingw32/include/windows.h:72,
                 from C:/Qt/6.2.3/mingw_64/include/QtCore/qt_windows.h:64,
                 from qtexttospeech_sapi.h:40,
                 from qtexttospeech_sapi.cpp:37:
C:/Qt/Tools/mingw900_64/x86_64-w64-mingw32/include/winuser.h:2965:43: error: variable 'CreateSyntheticPointerDevice' definition is marked dllimport
 2965 | WINUSERAPI HSYNTHETICPOINTERDEVICE WINAPI CreateSyntheticPointerDevice(POINTER_INPUT_TYPE pointerType, ULONG maxCount, POINTER_FEEDBACK_MODE mode);
      |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/Qt/Tools/mingw900_64/x86_64-w64-mingw32/include/winuser.h:2965:72: error: 'POINTER_INPUT_TYPE' was not declared in this scope; did you mean 'PRINTER_FONTTYPE'?
 2965 | WINUSERAPI HSYNTHETICPOINTERDEVICE WINAPI CreateSyntheticPointerDevice(POINTER_INPUT_TYP
 pointerType, ULONG maxCount, POINTER_FEEDBACK_MODE mode);
      |                                                                        ^~~~~~~~~~~~~~~~~
      |                                                                        PRINTER_FONTTYPE
C:/Qt/Tools/mingw900_64/x86_64-w64-mingw32/include/winuser.h:2965:110: error: expected primary-expression before 'maxCount'
 2965 | WINUSERAPI HSYNTHETICPOINTERDEVICE WINAPI CreateSyntheticPointerDevice(POINTER_INPUT_TYPE pointerType, ULONG maxCount, POINTER_FEEDBACK_MODE mode);
      |                                                                                                              ^~~~~~~~
C:/Qt/Tools/mingw900_64/x86_64-w64-mingw32/include/winuser.h:2965:120: error: 'POINTER_FEEDBACK_MODE' was not declared in this scope
 2965 | WINUSERAPI HSYNTHETICPOINTERDEVICE WINAPI CreateSyntheticPointerDevice(POINTER_INPUT_TYPE pointerType, ULONG maxCount, POINTER_FEEDBACK_MODE mode);
      |                                                                                                                        ^~~~~~~~~~~~~~~~~~~~~
C:/Qt/Tools/mingw900_64/x86_64-w64-mingw32/include/winuser.h:2965:146: error: expression list treated as compound expression in initializer [-fpermissive]
 2965 | WINUSERAPI HSYNTHETICPOINTERDEVICE WINAPI CreateSyntheticPointerDevice(POINTER_INPUT_TYPE pointerType, ULONG maxCount, POINTER_FEEDBACK_MODE mode);
      |                                                                                                                                                  ^
C:/Qt/Tools/mingw900_64/x86_64-w64-mingw32/include/winuser.h:2966:93: error: 'POINTER_TYPE_INFO' does not name a type; did you mean 'POINTER_64_INT'?
 2966 | WINUSERAPI WINBOOL WINAPI InjectSyntheticPointerInput(HSYNTHETICPOINTERDEVICE device, CONST POINTER_TYPE_INFO* pointerInfo, UINT32 count);
      |                                                                                             ^~~~~~~~~~~~~~~~~
      |                                                                                             POINTER_64_INT
```

Based on a tip mentioned in a related issue [QTEXT-14](https://bugreports.qt.io/projects/QTEXT/issues/QTEXT-14), workaround this by including `windows.h`, before including `qt_windows.h`.
Copy link

cla-assistant bot commented Nov 15, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@caarmen
Copy link
Author

caarmen commented Nov 15, 2024

CLA assistant check Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.You have signed the CLA already but the status is still pending? Let us recheck it.

I don't see how to submit anything on the CLA page:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant