有没有一些方法可以更改 Qt Creator 语法突出显示的设置?

Are there some ways to change settings of Qt Creator syntax highlighting?

我在 Ubuntu 18.10 中使用基于 Qt 5.11.1 的 Qt Creator 4.6.2 使用 .pro 文件中的 CONFIG += console c++17 键进行 C++ 编程,我遇到了以下问题代码:

std::for_each(attributes.begin(), attributes.end(), [&,i{0}](auto it) mutable {compressed.col_id[i] = it.first; i++;});

Qt Creator 将此代码用红色下划线并表示 "expected token ';' got '{'" 但编译器 运行 编译此代码没有问题。 此外,当我尝试 运行 此代码时:

int i = 0;
std::for_each(attributes.begin(), attributes.end(), [&](auto it) mutable {compressed.col_id[i] = it.first; i++;});

Qt Creator 没有下划线。

我认为 IDE 中的解析可能存在一些问题,我该如何处理?

尝试使用 C++ 的 ClangCodeModel。它在您的版本中可能是实验性的,但我也在那里使用过它。虽然可能会很慢。

C++ 的 Clang 代码模型已升级到 libclang 6.0,并在 QtCreator 4.7.0 中默认打开,因此使用 4.7.0 或更高版本的任何人都不会遇到此问题。

我发现 OP 代码由于不同的原因无法编译...it.first 应该只是 it

但在更改之后,代码可以正常编译:

CONFIG += c++14

或与

CONFIG += c++1z

语法高亮器没有任何投诉