Code Model

The Clang code model offers services such as code completion, syntactic and semantic highlighting, and diagnostics.

To configure the Clang code model globally:

  1. Select Preferences > C++ > Code Model.

    {C++ Code Model preferences}

  2. To instruct the code model to interpret ambiguous header files as C language files if you develop mainly using C, select the Interpret ambiguous headers as C headers check box.
  3. To process precompiled headers, deselect the Ignore precompiled headers check box.
  4. To use the built-in preprocessor to show the pre-processed source file in the editor, select Use built-in preprocessor to show pre-processed files.
  5. To avoid out-of-memory crashes caused by indexing huge source files that are typically auto-generated by scripts or code, the size of files to index is limited to 5MB by default. To adjust the limit, edit the value for the Do not index files greater than check box. To index all files, deselect the check box.
  6. To ignore files that match wildcard patterns, select the Ignore files check box and enter each wildcard pattern on a separate line in the field.

Inspect preprocessed C++ code

To analyze the causes of compile errors or errors caused by wrong includes pulled in by dependencies or C++ macros expanding to something unexpected, select Show Preprocessed Source in the editor context menu.

This action expands all C++ macros to their actual code and removes code that is guarded by a currently inactive #ifdef statements.

If you clear Use built-in preprocessor to show pre-processed files, this action also expands all "#include <foo.h>" statements to their actual contents.

See also Specify clangd settings, Clang Code Model, and Clangd.

© 2024 The Qt Company Ltd. 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.