简体   繁体   中英

Visual Studio Code doesn't “Find all references” in #define and macros

Visual Studio Code doesn't see references in #defines or macros, but Visual Studio does. Is there a setting that I don't see, that enables this?

Visual Studio 代码屏幕截图

[EDIT] To show that Visual Studio (IDE) does resolve the #define reference, I took another screenshot.

Visual Studio IDE 屏幕截图

Visual Studio Code (especially the C/C++ Extension) does a good job. Sometimes a reference cannot be resolved, in that case a restart or clearing/resetting the intellisense cache helps. But it could be also a configuration error.

In, File -> Preferences -> Settings

  • in the field 'Search settings', type include. Control every entry found.

Or

[CTRL] + [SHIFT] + P

  • C/C++: Rescan Workspace
  • C/C++: Reset IntelliSense Database

Addendum

I realized it a little too late but like i mentioned it in my comment below, you have a misconception.

Analog to your problem:

char *FOO = "bar";
int bar = 1;

I don't think you expect the string literal "bar" to be a reference to the variable int bar ?

Well, in your case #define FOO bar , bar is just a literal and has no relation to the variable bar in your main function.

I previously thought, that you have defined bar somewhere else and Visual Studio Code couldn't resolve it, but that's not the case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM