diff options
author | Stefan Sichler <stsichler@web.de> | 2022-11-29 14:39:55 +0100 |
---|---|---|
committer | Stefan Sichler <stsichler@web.de> | 2022-11-30 08:34:37 +0100 |
commit | f60d6f4ffa66f77ecfa925355b3762951ee5171e (patch) | |
tree | 6644e1f99667e06772931a5bc7da2c73db4b0a47 /src/tools/moc/moc.cpp | |
parent | b6e30e9fee98f9cdfec4c54c980864f65632519c (diff) |
moc: don't include any std headers before user class headers
don't `#include <memory>` before including the header of the user's
class(es), because the user may want to configure certain aspects of
stl/crt before including any standard headers.
Change-Id: I58f13d3604358221e3375a309eb747efecf3f990
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/tools/moc/moc.cpp')
-rw-r--r-- | src/tools/moc/moc.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 0fbadfc061..cc6e1b59e5 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -1072,7 +1072,9 @@ void Moc::generate(FILE *out, FILE *jsonOutput) fprintf(out, "** WARNING! All changes made in this file will be lost!\n" "*****************************************************************************/\n\n"); - fprintf(out, "#include <memory>\n"); // For std::addressof + // include header(s) of user class definitions at _first_ to allow + // for preprocessor definitions possibly affecting standard headers. + // see https://codereview.qt-project.org/c/qt/qtbase/+/445937 if (!noInclude) { if (includePath.size() && !includePath.endsWith('/')) includePath += '/'; @@ -1108,6 +1110,8 @@ void Moc::generate(FILE *out, FILE *jsonOutput) #endif ); + fprintf(out, "\n#include <memory>\n\n"); // For std::addressof + fprintf(out, "#if !defined(Q_MOC_OUTPUT_REVISION)\n" "#error \"The header file '%s' doesn't include <QObject>.\"\n", fn.constData()); fprintf(out, "#elif Q_MOC_OUTPUT_REVISION != %d\n", mocOutputRevision); |