summaryrefslogtreecommitdiffstats
path: root/src/tools/moc
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/moc')
-rw-r--r--src/tools/moc/generator.cpp12
-rw-r--r--src/tools/moc/moc.cpp6
2 files changed, 13 insertions, 5 deletions
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp
index b80e013ba4..7c0d579df4 100644
--- a/src/tools/moc/generator.cpp
+++ b/src/tools/moc/generator.cpp
@@ -257,7 +257,7 @@ void Generator::generateCode()
" uint(sizeof(qt_meta_stringdata_%s_t::offsetsAndSizes) + ofs), len \n",
qualifiedClassNameIdentifier.constData());
- fprintf(out, "static const qt_meta_stringdata_%s_t qt_meta_stringdata_%s = {\n",
+ fprintf(out, "Q_CONSTINIT static const qt_meta_stringdata_%s_t qt_meta_stringdata_%s = {\n",
qualifiedClassNameIdentifier.constData(), qualifiedClassNameIdentifier.constData());
fprintf(out, " {");
{
@@ -329,7 +329,7 @@ void Generator::generateCode()
//
int index = MetaObjectPrivateFieldCount;
- fprintf(out, "static const uint qt_meta_data_%s[] = {\n", qualifiedClassNameIdentifier.constData());
+ fprintf(out, "Q_CONSTINIT static const uint qt_meta_data_%s[] = {\n", qualifiedClassNameIdentifier.constData());
fprintf(out, "\n // content:\n");
fprintf(out, " %4d, // revision\n", int(QMetaObjectPrivate::OutputRevision));
fprintf(out, " %4d, // classname\n", stridx(cdef->qualified));
@@ -506,7 +506,7 @@ void Generator::generateCode()
//
if (!extraList.isEmpty()) {
- fprintf(out, "static const QMetaObject::SuperData qt_meta_extradata_%s[] = {\n",
+ fprintf(out, "Q_CONSTINIT static const QMetaObject::SuperData qt_meta_extradata_%s[] = {\n",
qualifiedClassNameIdentifier.constData());
for (int i = 0; i < extraList.count(); ++i) {
fprintf(out, " QMetaObject::SuperData::link<%s::staticMetaObject>(),\n", extraList.at(i).constData());
@@ -517,7 +517,9 @@ void Generator::generateCode()
//
// Finally create and initialize the static meta object
//
- fprintf(out, "const QMetaObject %s::staticMetaObject = { {\n", cdef->qualified.constData());
+ fprintf(out, "%sconst QMetaObject %s::staticMetaObject = { {\n",
+ // ### FIXME: gadgets are not constinit on Windows!
+ cdef->hasQGadget ? "" : "Q_CONSTINIT ", cdef->qualified.constData());
if (isQObject)
fprintf(out, " nullptr,\n");
@@ -1612,7 +1614,7 @@ void Generator::generatePluginMetaData()
// compatibility with Qt 6.0-6.2
fprintf(out, "#else\nQT_PLUGIN_METADATA_SECTION\n"
- "static constexpr unsigned char qt_pluginMetaData_%s[] = {\n"
+ "Q_CONSTINIT static constexpr unsigned char qt_pluginMetaData_%s[] = {\n"
" 'Q', 'T', 'M', 'E', 'T', 'A', 'D', 'A', 'T', 'A', ' ', '!',\n"
" // metadata version, Qt version, architectural requirements\n"
" 0, QT_VERSION_MAJOR, QT_VERSION_MINOR, qPluginArchRequirements(),",
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
index 5ea79a4280..e931e32f4e 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -1103,6 +1103,12 @@ void Moc::generate(FILE *out, FILE *jsonOutput)
" much.)\"\n", QT_VERSION_STR);
fprintf(out, "#endif\n\n");
+#if QT_VERSION <= QT_VERSION_CHECK(7, 0, 0)
+ fprintf(out, "#ifndef Q_CONSTINIT\n"
+ "#define Q_CONSTINIT\n"
+ "#endif\n\n");
+#endif
+
fprintf(out, "QT_BEGIN_MOC_NAMESPACE\n");
fprintf(out, "QT_WARNING_PUSH\n");
fprintf(out, "QT_WARNING_DISABLE_DEPRECATED\n");