Skip to content

Dim unused includes when editor.showUnused is enabled. #10490 #14857

Open

Description

@ldesandcco

Environment

  • OS and Version: Win11
  • VS Code Version: 1.144.1
  • C/C++ Extension Version: 1.35.6

Bug Summary and Steps to Reproduce

I use an umbrella include file in my projects for my all my source files to use. It is named includes.h
so each of my source files just has #include "headers.h" at the top.

I have allways found it stupid to add #inclues to each source file that are common amongst many source files.
its just silly repition.

The issue with the update, is now many of my #includes are dimmed out.
as an example these are dimmed out, but yet ther ARE used in source files.

#pragma once

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
#include <math.h>
#include <time.h>

The ONLY way they should get dimmed is if its never used anywhere in the project.

Configuration and Logs

{
  "configurations": [
    {
      "name": "ESP-IDF",
      "compilerPath": "J:\\ESP_6.1.0\\.espressif\\v6.1\\tools\\xtensa-esp-elf\\esp-15.2.0_20251204\\xtensa-esp-elf\\bin\\xtensa-esp32s3-elf-gcc.exe",
      "compileCommands": "${config:idf.buildPath}/compile_commands.json",
      "intelliSenseMode": "${default}",
      "includePath": [
        "${workspaceFolder}/**"
      ],
      "browse": {
        "path": [
          "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
      }
    }
  ],
  "version": 4
}

Other Extensions

No response

Additional context

No response

Activity

  1. Colengms commented on Nov 4, 2026

    @Colengms
    Contributor

    Hi ldesandcco . It's currently by-design that, by default, include statements will be dimmed as (semantically) unused if they have already been included (including if nested within a prior include), such that they could be removed without incurring a compilation error. The feature can be configured using a .editorconfig file. This feature is common between cpptools and Visual Studio. It looks like you may want to alter cpp_include_cleanup_add_missing_error_tag_type. If the .editorconfig variables don't provide sufficient flexibility for your scenario, please let us know what's missing.

  2. changed the title [-]Dim unused local variables and parameters when editor.showUnused is enabled. #10490[/-] [+]Dim unused includes when editor.showUnused is enabled. #10490[/+] on Nov 4, 2026
  3. Colengms commented on Nov 4, 2026

    @Colengms
    Contributor

    I think I see the issue. I believe (some of) the dimming you are seeing is intended to be opted into, and the default (of cpp_include_cleanup_remove_unused_error_tag_type) is not being set (or read) properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

  • Status
    In progress

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions