27

When trying to compile my c++ code with Cheerp (using clang++), I get this output from my terminal:

example.cpp:102:9: error: invalid operands to binary expression ('std::ostream'
      (aka 'basic_ostream<char>') and 'const char *')
    out << "(" << loc.x << ", " << loc.y << ")";
    ~~~ ^  ~~~

Here is my command to the terminal:

/opt/cheerp/bin/clang++ -target cheerp example.cpp -o example.js

And Here is the code it has trouble with:

static std::ostream& operator <<(std::ostream & out, const CornerLoc &loc)
{
    out << "(" << loc.x << ", " << loc.y << ")";
    if (loc.type == kCorner)
        out<<"-corner";
    if (loc.type == kCornerNorthWest)
        out<<"-cornerNW";
    if (loc.type == kCornerNorthEast)
        out<<"-cornerNE";
    if (loc.type == kCornerSouthWest)
        out<<"-cornerSW";
    if (loc.type == kCornerSouthEast)
        out<<"-cornerSE";
    return out;
}
Xunie
  • 437
  • 4
  • 21
Jonathan Allen Grant
  • 3,408
  • 6
  • 30
  • 53
  • I guess your standard library headers are corrupted. – Lingxi Jan 30 '16 at 22:15
  • @Lingxi how can I fix them? – Jonathan Allen Grant Jan 30 '16 at 22:15
  • Just a guess. I'm not sure. Try compile the code in question on an online compiler (e.g., [Wandbox](http://melpon.org/wandbox)) and see whether the problem remains. – Lingxi Jan 30 '16 at 22:18
  • 1
    To whoever is reviewing this: It has all the details it needs. One would really not expect `ostream << cstr` to not work and this is literally how this issue presents itself. What other information do you want? A memory dump? It's exactly what this question needs to be to help others with the same issue. – Tomáš Růžička Mar 13 '23 at 11:32

1 Answers1

52

FIXED:: I just forgot to #include <iostream>

Jonathan Allen Grant
  • 3,408
  • 6
  • 30
  • 53