OpenAmiga (899/959)

From:Gregory Roberts II
Date:31 Aug 2000 at 16:04:29
Subject:Re: AMIOPEN: vpcc as a C++ compiler

Hi Henrik,

On Thu, 31 Aug 2000, Henrik Munther wrote:

> it is not a initializer problem, but a destructor problem. If a class
> has a destructor it will cause an exception when initializing, unless
> you declare it as a pointer and allocate it by new.
> And as fstream has a destructor you have the problem...

Aha! Apparently I either missed or didn't quite understand the nature of
the problem (perhaps a function of late night e-mail reading :). This
makes perfect sense now and I think it might help with the problems I'm
having. Exactly the sort of info I was looking for.

Just to make sure I understand, if I do:

ofstream * fout;

fout = new ofstream;
fout->open("hello.out");
... etc ...
fout->close();
delete fout;

it should work, right?

>
> I wonder how Tao can make a c++ compiler without having encountered
> this...
>

Makes me wonder too, but evidently there seems to be a lot more focus on
VPASM and such.... oh well, mark it up to growing pains I guess.

> eg. the following example will crash:
>
> class Foo
> {public:
> Foo() {}
> ~Foo() {}
> };
>
> int main(int argc, char **argv)
> { Foo t;
> }
>

Very, very bad! Looks like I'll have to mod a bunch of code to work
around this. :-(

Thanks for the quick and informative reply!

Greg



gregr@en.com
Developing for Ami (Amiga OE)
"So the World May Know"
d'Amiga, A3000, A2000, A1200, A1000x2

Subscribe/Unsubscribe: open-request@amiga.com
Amiga FAQ: http://www.amiga.com/faq.html