Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Greyed out code in VS Code with the C/C++ and TypeLens extensions

i'm trying to solve the following issue with VS Code and the C/C++ Extension from Microsoft.

The mentioned Extension adds a reference count above every function/object definition in the source code. That's a helpful feature so far, but for me it doesn't work as intended I think.

In my example I started implementing a thread-safe linked list to practice (please ignore the code, thats not what this topic is about). The whole class is greyed out although I import the header-file and instantiate an object of that class in the main.cpp file in the main-function. Also, the whole main function is greyed out because no references to the main-function are found. That makes no sense to me, why would I ever reference the main-function in my code? It's the entry point to the program and shouldn't be referenced in my project source code afaik.

When I disable the C/C++ Extension, the reference counts are gone and the source code is highlighted again. But I would really like to keep the reference count and only get rid of the greyed out code (or make it work properly so that main function and definitions I reference in my code are not greyed out).

Also by disabling the extension, code auto completion is gone. So that's not a good trade. I spent hours of reading the configuration and searching the web for solutions, but I couldn't find anything helpful. The only thing slightly realted to the greying out of code I found is the option "Dim inactive regions" found in the C/C++ Extension's setting. But it didn' solve my problem.

Thank you in advance for reading/trying to help!

Example of greyed out code and reference count:

Example of greyed out code and reference count

greyed out main function because of 0 references to main:

greyed out main function because of 0 references to main

Dim inactive code option:

Dim inactive code option

Update: So it turned out that the reference counter not only disappears when I disable the C/C++ extension but also when I disable the TypeLens extension. That does not solve my problem but at least I can get rid of the greyed out code by disabling TypeLens and still use the auto completion the C++ extension provides.

like image 423
bsod87 Avatar asked Oct 30 '25 03:10

bsod87


1 Answers

As I mentioned in the updated question, the problem isn't realted to the C/C++ Extension. It is acutally the TypeLens extension that causes problems here.

The best solution I have found is to configure TypeLens to not grey out unreferenced code. This way I can keep the reference counter and the code completion feature from the C/C++ extension but prevent the source code from being greyed out by TypeLens.

To achieve this, you have to set the Typelens:Unusedcolor value from #999 to nothing (just delete the value).

like image 120
bsod87 Avatar answered Oct 31 '25 18:10

bsod87



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!