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

qt library: Make Q_PROPERTY a variadic macro to avoid preprocessorErrorDirective #5370

Merged
merged 1 commit into from
Aug 25, 2023

Conversation

vb-linetco
Copy link
Contributor

@vb-linetco vb-linetco commented Aug 25, 2023

Treat Q_PROPERTY as variadic macro to avoid preprocessorErrorDirective with associative container templates itroducing a "," like for example QHash<QString, int>. Using templates is totally fine in the context of a moc compiler.

The macro Q_PROPERTY is defined as variadic in qobjectdefs.h/qtmetaobject.h when not compiling using the moc compiler.

See following references:

@chrchr-github
Copy link
Collaborator

Thanks for your contribution. Can you add a test in qt.cpp?

@vb-linetco
Copy link
Contributor Author

Thanks for your contribution. Can you add a test in qt.cpp?

Sure, I'll have a look, didn't notice there were tests for that

@vb-linetco
Copy link
Contributor Author

Thanks for your contribution. Can you add a test in qt.cpp?

I've added a test and verified, that without the (...) for the Q_PROPERTY Macro the test fails.

test/cfg/qt.cpp Outdated Show resolved Hide resolved
Treat Q_PROPERTY as variadic macro to avoid preprocessorErrorDirective with associative
container templates itroducing a "," like for example `QHash<QString, int>`.
Using templates is totally fine in the context of a moc comiler.

The macro Q_PROPERTY is defined as variadic in qobjectdefs.h/qtmetaobject.h when not compiling
using the moc compiler.

See following references:
* For Qt 5.15 https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/kernel/qobjectdefs.h?h=5.15#n104
* For Qt 6.6 https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/kernel/qtmetamacros.h?h=6.6#n5

Add test to verify Q_PROPERTY with QHash<QString, int> works properly
@chrchr-github chrchr-github merged commit 078e967 into danmar:main Aug 25, 2023
72 checks passed
@chrchr-github
Copy link
Collaborator

Would you like to be credited as an author, and if so, which name should be used?

@vb-linetco
Copy link
Contributor Author

vb-linetco commented Aug 26, 2023

Would you like to be credited as an author, and if so, which name should be used?

Yes and please use Valentin Batz (LiNetCo GmbH), thank you.

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

Successfully merging this pull request may close these issues.

2 participants