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

Re: Is cris also c++ compiler?



Hi,
I am involved in an c++ project on the etrax 100, so I am interested in:
why do you have to overload the operators new and delete ??
makes me curious,
Praxmarer Robert.

Jonas Holmberg wrote:

> > 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