6

New install of VSCode. The only extension I have installed is the Microsoft C/C++ Intellisense plugin. Version 0.24.1

I'm working with a codebase that has some header files with #define X foo macros. In the .cpp files it underlines these in red and says "identifier X is undefined". However if I ctrl+click/F12 it takes me to the .h file(s) with the macro defined.

This is the only extension I have right now so I don't think it's an issue of plugins competing. It seems common to macros with multiple definitions. i.e. we have

chipset1/include/registers.h and

chipset2/include/registers.h

which might both #define REG1 0xF00 or similar. However I only have "${workspaceFolder}/chipset1/include" in my .vscode/c_cpp_properties.json file. So I don't know why it's searching the chipset2 definitions as well. Perhaps this is causing the issue and the error message is misleading and should really say something like "multiple definitions found"? Still unsure why this behavior is occurring.

brenzo
  • 677
  • 2
  • 6
  • 11
  • Why do you care what intellisense says? What *matters* is what the actual compiler says. Intellisense is just (unreliable) sugar in your IDE. – Jesper Juhl Aug 14 '19 at 19:20
  • 22
    Yes of course, but I'd like to use intellisense without having all my source files covered in red lines. – brenzo Aug 14 '19 at 19:22
  • @brenzo Try closing the project and deleting the intellisense database file from your project. It will be regenerated the next time you open your project. – François Andrieux Aug 14 '19 at 20:50
  • Unfortunately this did not resolve the issue. – brenzo Aug 15 '19 at 15:49
  • This might not be the exact same issue, but this solution helped me (I also had these annoying red lines): https://stackoverflow.com/a/56008710/5462551 – noamgot Jan 23 '20 at 10:00

1 Answers1

1

Replace this line in c_cpp_properties.json: "configurationProvider": "ms-vscode.cmake-tools"

With: "configurationProvider": "ms-vscode.cpptools-tools"