From b6bfb178a061cd944ca98c9638fbeefe9f51b565 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 21 Jun 2022 10:40:20 -0700 Subject: [PATCH] moc: replace offsetof with sizeof It's the same thing since we have exactly one field in this structure before stringdata0. But there's a far smaller chance of producing a warning in user code. Change-Id: Id0fb9ab0089845ee8843fffd16f9cdceec33017d Reviewed-by: Fabian Kosmale (cherry picked from commit 9959cf60d360a43c87c77f44a7d17e2fae25a303) Reviewed-by: Qt Cherry-pick Bot --- src/tools/moc/generator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index d86c58c7bc6..6efc24a6e11 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -254,7 +254,7 @@ void Generator::generateCode() // Macro that simplifies the string data listing. The offset is calculated // from the top of the stringdata object (i.e., past the uints). fprintf(out, "#define QT_MOC_LITERAL(ofs, len) \\\n" - " uint(offsetof(qt_meta_stringdata_%s_t, stringdata0) + ofs), len \n", + " 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",