qt5.14+ moc bug(handle include directives in enums)

問題1

The moc process failed to compile
    "SRC:/..............."
into
    "Src:/................................."
command
--------
path/to/path

問題2

tbb/tbb_profiling.:28: Parse error at "{"

問題分析

該bug在5.14已經出現過,5.15仍然未能解決,問題的原因在於moc過程中不支持處理enum包含#include頭文件的語法。

解決方案1

  • 下載qt-everywhere-src-5.15.0源代碼。
  • 進入qt-everywhere-src-5.15.0\qtbase\src\tools\moc
  • qtcreator雙擊打開moc.pro
  • 修改文件moc.cpp,然後重新編譯即可。加入代碼如下圖:
    在這裏插入圖片描述
    也可以複製一下代碼:
if (!test(LBRACE))
    return false;
auto handleInclude = [this]() {
        if (test(MOC_INCLUDE_BEGIN))
            currentFilenames.push(symbol().unquotedLexem());
        if (test(NOTOKEN)) {
            next(MOC_INCLUDE_END);
            currentFilenames.pop();
        }
    };
do {
    if (lookup() == RBRACE) // accept trailing comma
        break;
    handleInclude();
    next(IDENTIFIER);
    def->values += lexem();
     handleInclude();
    skipCxxAttributes();
} while (test(EQ) ? until(COMMA) : test(COMMA));

解決方案2

從以下下載程序,替換原來的moc.exe程序即可。

原博文:qt5.14+ moc bug(handle include directives in enums)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章