0

I have a large c/c++ project containing a lot of #define macros defined in headers. VSCode "find all references" find only the definition in header file but not it usage in cpp files. I am using Visual Studio Code with Clangd extension with a remote server indexation. The arguments I am using are:

--enable-config
--header-insertion=iwyu
--header-insertion-decorators=true
--all-scope-completion
--include-cleaner-stdlib

Is there a way to for the indexation of those header containing #define ? If not can I mix clangd search in VSCode with Ctags technology which works fine with #define macros?

Example

MyHeader.hpp

#define MyVariable 3
enum Variables
{ myEnum = 3}
MyFile1.cpp

func()
{ 
  use MyVariable;
  use Variables::myEnum;
}
MyFile2.cpp
functwo()
{ 
  use MyVariable;
  use Variables::myEnum;
}

If I do the research on MyVariable on the MyHeader.hpp file, it will find only the header file whereas if I do it on myEnum it will find MyHeader.hpp, MyFile1.cpp and MyFile2.cpp

amestin
  • 31
  • 1
  • 3
  • I don't fully understand the question. Are you performing "search all references" on a macro symbol, and failing to find occurrences? Are you performing the search from the definition of the macro or from a use? Are the missing references in header or cpp files? An example would be helpful. – HighCommander4 Aug 19 '22 at 21:38
  • Yes exactly. The missing references are in cpp files. – amestin Aug 22 '22 at 08:40
  • I just tested this with example code files similar to what you posted, and for me, searching for `MyVariable` in the header files **does** find the references in the cpp files. So, maybe you're running into an issue relating to a specific code pattern, and need to provide a more specific code example to diagnose it. – HighCommander4 Aug 22 '22 at 17:21

0 Answers0