vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

Find All References doesn't find references in preprocessor statements (also affects Rename Symbols)

Open sean-mcmanus opened this issue 7 years ago • 9 comments

#define DEF1 1
#define DEF2 DEF1

#ifdef DEF1

int main(){
    return DEF1;
}
#endif

Bug: Find All References only finds the "return DEF1;" and not the cases in the #define/#ifdef. VS handles that case correctly.

It also affects rename (which uses find all references).

sean-mcmanus avatar Aug 13 '19 18:08 sean-mcmanus

As I don't have access to VS atm, can You maybe tell me what would be the case with the following code, if I want to see all references to myVariable?

#define DEF1 myVariable
#define DEF2 DEF1

int main(){
    return DEF1 + DEF2;
}

VS Code won't find any references for myVariable at the moment, will this change with this issue in the future too?

Joinyy avatar Aug 26 '19 12:08 Joinyy

The fix for this bug would only find the line "#define DEF1 myVariable" and not the uses of the macro DEF1.

sean-mcmanus avatar Aug 26 '19 22:08 sean-mcmanus

Is there any plan for this issue to be fixed?

jenuc78 avatar Jan 15 '21 23:01 jenuc78

Yes, eventually -- it should be fixed after we've unified the VS and VS Code more. From what I recall, there was a component missing for handling this case correctly, but it's possible I'm remembering incorrectly and could double-check later (might take a while since I have higher priority failures to investigate).

sean-mcmanus avatar Jan 16 '21 00:01 sean-mcmanus

Renaming a C/C++ macro is a much needed feature in any C/C++ IDE. Added my upvote, hopefully VSCODE will have it soon.

kobyfr avatar Mar 26 '23 05:03 kobyfr

Is there any hope of fixing this BUG?

meijialun avatar May 21 '24 03:05 meijialun

Is there any workaround to find variables that are mentioned in a preprocessor directive in visual studio code?

zhouaea avatar Jan 08 '25 16:01 zhouaea

One year has passed, and I'm still looking for a solution to this problem. However, I'm very frustrated because the problem still exists. 😥

meijialun avatar May 07 '25 02:05 meijialun

6 years passed since this issue was originally created. Looking at the history it seems that the developer that created this issue (@sean-mcmanus ) unassigned himself from the issue. Later, automation moved the issue to triage, aftter which @bobbrow removed it from triage and has remained with no status since 20 jun 2024.

Could we get a status update so we at least know if this ever has a chance of being fixed?

Some areas of work make (or even require) heavy use of macro aliasing (like AUTOSAR). If Microsoft wants to attract more commercial customers towards VSCode, issues like this really need to be addressed (since correct symbol navigation inside an IDE is a core feature).

scorpyonmike avatar Jul 17 '25 07:07 scorpyonmike