代码模型
代码模型提供代码补全、语法和语义高亮以及诊断等服务。
要全局配置 C++ 代码模型,请访问首选项>C++ >Code Model 。
下表概述了首选项。
设置 | 值 |
---|---|
Interpret ambiguous headers as C headers | 指示代码模型将模棱两可的头文件解释为 C 语言文件。如果您主要使用 C 语言开发,请选择此复选框。 |
Ignore precompiled headers | 清除此复选框以处理预编译头文件。 |
Use built-in preprocessor to show pre-processed files | 使用内置预处理器在编辑器中显示预处理源文件。 |
Enable indexing | 打开内置索引器。清除此复选框会严重限制代码模型的功能。 |
Do not index files greater than | 为避免因索引通常由脚本或代码自动生成的巨大源文件而导致内存不足崩溃,索引文件的大小默认限制为 5MB。 要索引所有文件,请清除复选框。 |
Ignore files | 要忽略与通配符模式匹配的文件,请在字段中单独一行输入每个通配符模式。 |
检查预处理的 C++ 代码
要分析编译错误的原因,或因依赖项或 C++ 宏扩展到意外内容而导致的错误,请在编辑器上下文菜单中选择Show Preprocessed Source 。
该操作会将所有 C++ 宏扩展为实际代码,并删除由当前未激活的#ifdef
语句保护的代码。
如果清除了Use built-in preprocessor to show pre-processed files ,该操作也会将所有"#include <foo.h>"
语句展开为其实际内容。
另请参阅 配置 C++ 代码模型、指定 clangd 设置、Clang 代码模型和Clangd。
Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.