Skip to main content
Associate II
March 30, 2026
Question

#ifdef highlight doesn't corresponds to actual state

  • March 30, 2026
  • 1 reply
  • 175 views

Hello,

Before compilation: Screenshot from 2026-03-30 15-43-52.png

 

I’m having an issue with IntelliSense (possibly clangd).

When a macro is undefined, the code inside #ifdef is correctly shown as inactive (dimmed). However, after I build and flash the project, the same code becomes highlighted as if it were active, even though the macro mDEBUG is still not defined.

The highlighting only returns to the correct state after I switch tabs or force a refresh.

Is this expected behavior, or could this be a bug or bad config on my side? It brings confusion to my workflow.

After compilation: Screenshot from 2026-03-30 15-41-47.png

1 reply

mbarg.1
Senior III
March 30, 2026

run re-index and will be fixed.

Not all changes trigger this function.

Associate II
March 31, 2026

But that's the issue, shouldn't it re-index by itself? 

mbarg.1
Senior III
March 31, 2026

I found that some edits do not trigger automatic re-indexing or force project clean-up before compiling; I use STM32CubeIde, but it looks that same problems are with MS editor.

It seems that happens more often with auto-save, I did not see on manual save yet.

Be aware that MS and STM share some part of background engine and compiler/linker.

More, not all pre-processor directives run correctly, like in my post https://community.st.com/t5/stm32cubeide-mcus/stm32cubeide-bug-wrong-behavior-with-has-include-xxx-h/m-p/775926?search-action-id=109827300795&search-result-uid=775926