In my main.cpp, I include “MySensors.h” and the following error is notified “cannot open source file “SerialPort.h” (dependency of “MySensors.h”)C/C++(1696)”
But no error during compilation.
This error is only detected when I define “#define MY_RS485”
Thanks for the complete and minimal example. However, it works without a problem on my machine.
Where is the error message shown? Does it appear as a tooltip when hover over red squiggly lines in the source code editor? If so, can you show a screenshot of the Visual Studio Code extension you have installed?
None of the extensions looks suspicious. The main point is to restrict C/C++ extensions to the PlatformIO IDE extension and the C/C++ extension from Microsoft.
Can you first try the following steps to see if it makes any difference:
Delete the .pio folder in your project directory
Build the project
If it doesn’t fix it, can you compare the include paths in .vscode/c_cpp_properties.json with the following extract and check that the same paths are listed:
I think this is a linux-specific issue - probably exposed by the
#ifdef __linux__
#include "SerialPort.h"
#endif
reference in MySensors_ID548/hal/transport/RS485/MyTransportRS485.cpp. The file does exist at MySensors_ID548/drivers/Linux/SerialPort.h but doesn’t seem to be needed, but IntelliSense seems to be having trouble working down the pre-processor macro chain… i.e. after opening a few of the includes along the way… it’s no longer whining about SerialPort.h and now that it can’t open ‘string’… Anyway… unless this was code for the Raspberry Pi… You should be fine to ignore this errant IntelliSense warning.
Is the project building successfully in PlatformIO? → Use Ctrl+Shift+P → Rebuild IntelliSense to fix it.
If it is not building then there is a real problem. Please then open a new topic with all the details (platformio.ini, used code).
vscode After I added the library about TFT_eSPI from platformio libraries, main.There was an issue with header files showing red squiggly lines in c, and I restarted vscode and didn’t solve the problem.
You are using the TFT_eSPI library presumably from
which strictly declares compatibility with only the Arduino framework. You are attempting to use it with the ESP-IDF framework. This will not work, it needs the Arduino libraries.
The only way this can possible work is if you use the “ESP-IDF plus Arduino-ESP32 as a component” framework method as shown in this example. Otherwise you need to find a library that is compatible with only ESP-IDF and has no dependencies to Arduino.
You can also force the library compatibility check to be off, see docs with lib_compat_mode = off, but since the Arduino headers are probably not there in your project, this will run into a compilation failure.