leaningtech / cheerp-meta

Cheerp - a C/C++ compiler for Web applications - compiles to WebAssembly and JavaScript
https://labs.leaningtech.com/cheerp
Other
1.03k stars 51 forks source link

basic_iostream doesn't inherited from basic_ostream #68

Closed piggestbaby closed 6 years ago

piggestbaby commented 7 years ago

This sample code will fail when compiled with cheerp:

#include <string>
#include <sstream>
using namespace std;
// webMain is the entry point for web applications written in Cheerp.
void webMain()
{    
    string str;
    stringstream s;
    s << str;
}

It was caused by file istream line 1474:

template <class _CharT, class _Traits>
class _LIBCPP_TYPE_VIS_ONLY basic_iostream
    : public basic_istream<_CharT, _Traits>/*,
      public basic_ostream<_CharT, _Traits>*/
yuri91 commented 7 years ago

Hi,

The problem is that currently Cheerp does not support virtual base classes. They are used to solve the diamond problem of multiple inheritance, and since we cannot use them, we needed to remove one of the base classes of basic_iostream.

In this particular case it may not be an issue though, because you can use the ostringstream class:

#include <string>
#include <sstream>
using namespace std;
// webMain is the entry point for web applications written in Cheerp.
void webMain()
{    
    string str;
    ostringstream s;
    s << str;
}
alexp-sssup commented 6 years ago

Fixed as Cheerp 2.0RC2