[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Is cris also c++ compiler?



> Hello!

Hi!

> 
> Does gcc-cris compile c++ code?

Yes.

> Included is a printout, when I tried to compile this very simple c++
> program. Either there is something wrong with out 
> installation, or cris
> can't compile c++.
> 
> (filename koodi.cc:)
> #include <iostream.h>
> 
> int main(void){
>   cout << "Hello world by HTI!\n";
>   return 0;
> }

There is currently no elinux port of the standard C++ library so you cannot use iostreams (use stdio instead). You also need to overload the new and delete operators, like this for example:

void* operator new[](size_t mem_size)
{
  void* aHeapAddress = malloc(mem_size);
  return aHeapAddress;
}


void operator delete[](void* ptr)
{
  free(ptr);
}

void* operator new(size_t mem_size)
{
  void* aHeapAddress = malloc(mem_size);
  return aHeapAddress;
}


void operator delete(void* ptr)
{
  free(ptr);
}

Best regards
/Jonas Holmberg