Re: Question about mixing c++ exception handling & c code
<snip>
I am not sure what to expect if foo::dosomething raises an exception.
Is code safe for exception being traversing through c code.
In general, no. If a C++ exception is thrown out of C++ into any other
language, all bets are off. It is possible that this may work properly
in your environment. But I wouldn't put money on it (especially as any
C code won't be able to tidy itself up, as in:
void func(void)
{
char *buff = malloc(50);
if (buff == NULL) return;
if (call_function_which_happens_to_throw_an_exception())
{
do_something_exciting();
}
free(buff);
}
you'll definitely have a memory leak. Any C++ function which is extern
"C" definitely needs to do
extern "C" void xxxx()
{
try { .... } catch (...) { fprintf(stderr, "it went bang\n") };
}
sort of thing
Can I assume object which is being caught in scriptexecuter::execute
to be properly constructed one.
Consult your implementation documentation. If it doesn't say
explicitly you can do this, I'd be inclined to assume that you can't.
And even if your implementation can, it won't be portable.
Thank you for your advice.
Regards,
Abhijeet
Cheers
Tom
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]