Itellisense errors but build succeeds

I need some help so my project is on a atmega32u4 im utilising the avr/sleep library intellisense gives me these errors (the same is true for the PN532 stuff) the thing i dont understand is it builds and runs exactly as expected.

A snippet of my code is here:

#include <avr/interrupt.h>
  #include <avr/sleep.h>

  // This is the code that runs when the interrupt button is pressed and interrupts are enabled.
  void wakeUpNow() {}

  // Lets go to sleep.
  void sleepNow() {
    sleep_enable(); // Enables the sleep mode.
    attachInterrupt(0,wakeUpNow, HIGH);
    set_sleep_mode(SLEEP_MODE_PWR_DOWN); // Sleep mode is set here.

Platformio.ini contains

[env:sparkfun_promicro8]
platform = atmelavr
board = sparkfun_promicro8
framework = arduino
lib_deps = 
	wire
	featherfly/SoftwareSerial@^1.0
	dfrobot/DFRobotDFPlayerMini@^1.0.5
	miguelbalboa/MFRC522@^1.4.8
	ivanseidel/LinkedList@0.0.0-alpha+sha.dac3874d28
	https://github.com/clarketronics/PN532.git
	rocketscream/Low-Power@^1.6
monitor_port = COM12
monitor_speed = 115200

Please help!

Ctrl+Shift+P → Rebuild IntelliSense.

So that works for about 3minutes then it pops back up.

Well did you add a new library within those 3 minutes or change the project? Do you have other VSCode extensions installed besides C/C++ by Microsoft, PlatformIO, Python and Jupyter?

No, i waited the time. i actually walked away and came back.

image

The C++ Intellisense extension by austin is known to be make problems with PlatformIO, reported multiple times in this forum. The Microsoft one is all you need.

Ok, so ive removed that. Restarted vscode and rebuilt intellisense. The errors are still there.

Does the project still build? Delete the .pio and .vscode folder if in doubt and re-build the firmware and rebuild the intellisense.

ahhhh, looking through the c_cpp_properties.json noticed its deleted the reference i added to where the avr library’s are. I’ve added it back and it works now but why would it have deleted it in the first place?

The c_cpp_properties.json is a automatically generated file. It will be regenerated on every IntelliSense rebuild, which may be triggered as a post-action on a build, platformio.ini modification or an explicit rebuild command. You should not be editing this file. At best, you should use build_flags with -I <path to include folder> to add an include path, this will propagate into the c_cpp_properties.json after a rebuild.

What libraries are missing in the include path and where are they on your computer?

ok so i added this to the platformio.ini

build_flags = 
	-I "C:/Users/Rhys/.platformio/packages/toolchain-atmelavr/avr/include/avr"

Rebuilt intelisense and still got the warnings.