On 23/07/20 22:54, Thiago Macieira wrote:
On Thursday, 23 July 2020 12:34:06 PDT Simon Hausmann wrote:
I think the primary environment where a transition and resulting BC
breakage would be annoying is the Linux system environment with gcc. This
is where Olivier’s solution is quite elegant IMO.
I'd rather go to [[no_unique_address]] instead of this. The extension doesn't
compile in all cases (you can't have a Flexible Array Member everywhere) and
is going to produce warnings.
Let's just drop GCC 8.
You do not need to use the empty array everywhere: only in the helper type
created by the Q_PRIVATE_QPROPERTY macro. And it can be conditioned on
pre-c++20 GCC. And I did not see any warning on compiler explorer.
For reference, here is the proposed solution:
class MyClass : public QObject
{
// Generated by QT_PRIVATE_QPROPERTY
struct _qt_property_api_foo {
QString operator()();
void setValue(const QString &);
// ... more functions ...
char empty_array[0]; // That's a GCC extension
};
_qt_property_api_foo foo;
};
_______________________________________________
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development