Some ARDUINO keywords marked as problem

Hi guys,

I am new here in the community and making my first steps in PlatformIO.
ARDUINO I use since a few years and allways used ARDUINO IDE.
But with complex code it is really annoying…

So I came across PlatformIO.

But there is some strange behaviour.
I have a simple code using serial monitor and String objects.

It markes this line: Serial.begin(9600); as problem.
But this line: Serial.print("test: "); is OK.
And then the String objects declaration is marked as problem too.
Like this: String Tag_string;

But this code workes! And Arduino-IDE does it compile and workes fine on the chip.

What is the problem? I don’t understand?
Do I have to need a special config for ARDUINO?
Anybody can help me?

Thanks a lot.
MisterX

Did you #include "Arduino.h" at the top of your code? That would cause the red, wiggly, underlines which I think you mean when you say “marked as a problem”.

Even if you do have that #include present, VSCode (which I assume you are using) can sometimes lose the plot as far as “intellisense” is concerned. It’s intellisense, from Microsoft, which does the squiggly lines when it doesn’t understand something.

You can force it to reread the source files by:

  • View->Command Palette (or CTRL-SHIFT-P)
  • Search for intellisense
  • Choose PlatformIO rebuild intellisense index.

If that doesn’t help, try again, but this time, select “C++ Rebuild Intellisense index”.

Those options usually help. However, it can also be ignored. I have noticed in quite a few projects, that intellisense sees some of the Arduino code as ok, but gives me squiggles for others.

HTH

Cheers,
Norm.

Thanks Norm,

the #include Arduino.h brought the solution.
I’l have an eye on it.
I imported ARDUINO files so there is not that include, of course.

1 Like