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

RE: Is cris also c++ compiler?



Hello,
the reason is that the builtin new operators use _malloc() and there is no _malloc() in uC-libc. I guess you could modify uC-libc instead and make _malloc() an alias for malloc() (or if you are using another library you may not have to do anything).

brgds
/Jonas

> -----Original Message-----
> From: Cubic [mailto:cubic@xxxxxxx.at]
> Sent: Tuesday, November 28, 2000 7:04 PM
> To: Jonas Holmberg
> Cc: 'Timo.Hosti@xxxxxxx.fi'; dev-etrax
> Subject: 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
>