c++visual-studiointellisenseesp32visualmicro

Visual Studio (Intellisense) no operator std::ostringstream <<


I am using Visual Studio 16.5.3 with visual micro plugin (Release 20.03.21.2/3) to compile some ESP32 board sketches. I get a tedious error from the IDE, even tho the code compiles and runs fine. The relevant lines are:

std::ostringstream ss;
ss << "LIGHT: ";

I included <iostream>, <string>, <sstream> and <ostream>

The IDE is complaining about missing << operator, with operands of type std::stringstream and const char[8]. The actual message is (sorry for italian, I guess it's clear anyway):

"C++ nessun operatore corrispondente agli operandi i tipi di operando sono: std::ostringstream << const char [8]"

That would sound something like "no operator << for the operands..."


Solution

  • Visual Studio (Intellisense) no operator std::ostringstream <<

    First, you should put the below code under function or main body and then import several head file as you showed above.

    Like this:

    enter image description here

    So if you still face the issue and build the project without any errors, I think it is Intellisense's problem. And you can see that it works well in my side. And you can try this:

    Suggestion:

    1) close VS Instance, delete .vs hidden folder, bin, obj folder and then reopen your project again.

    2) disable any unrelated third-party extensions under Extensions-->Manage Extensions or use devenv /safemode to start VS to test whether it is caused by other extensions.

    In addition, if this issue still persists, please share the sample code with us so that we can troubleshoot it as soon as possible.

    Any feedback will be expected.