[R] Error messages and C

Vadim Ogranovich vograno at evafunds.com
Fri Aug 20 22:09:46 CEST 2004

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Ross Boylan
> Sent: Friday, August 20, 2004 11:35 AM
> To: r-help
> Subject: [R] Error messages and C
> I am calling a C (C++ really) function via the .C interface.
> Sometimes when things go wrong I want to return an error message.
> 1.  R provides C functions error and warning which look about right. 
> But exactly how does this exit, and in particular what 
> happens with cleaning up, calling C++ destructors, and 
> unwinding the stack?  Will I get memory leaks?

I've run across this issue and I couldn't find a satisfactory solution
to the problem. error() is effectively a long jump. Moreover, if your
C++ function calls an R API function, e.g allocVector(), and the latter
calls error() ... you already know what will happen. Same for

More information about the R-help mailing list