Skip to content

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

Merged
chrchr-github merged 1 commit intocppcheck-opensource:mainfrom
vb-linetco:main
Aug 25, 2023
Merged

qt library: Make Q_PROPERTY a variadic macro to avoid preprocessorErrorDirective#5370
chrchr-github merged 1 commit intocppcheck-opensource:mainfrom
vb-linetco:main

Conversation

@vb-linetco
Copy link
Copy Markdown
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
Copy Markdown
Collaborator

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

@vb-linetco
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread test/cfg/qt.cpp Outdated
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 cppcheck-opensource:main Aug 25, 2023
@chrchr-github
Copy link
Copy Markdown
Collaborator

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

@vb-linetco
Copy link
Copy Markdown
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