I tried both solutions but I always get "undefined symbol" when executing
I have checked my Makefile and I'm sure that -lR is present when compiling I did a grep for the R-sources and verified that both functions exists I will try to post it in r-devel list. Thank for yours responses dear Martin and Luke. Jorge El Mié 20 Ago 2008, Luke Tierney escribió: > On Wed, 20 Aug 2008, Martin Morgan wrote: > > Hi Jorge -- > > > > I hesitate to suggest this unsupported solution (as these public > > suggestions tend to mean that the solution disappears!), but in C > > Don't use this -- it is subject to change/removal with no notice. > > I do not believe there is a C level methanism for catching the R error > conditon at this point. Thinking about this is on the list but it > hasn't happened yet. One thing you can do is use the geterrmessage R > function to retrieve the most recent message (so if R_tryEval > indicates an error occurred then build and execute a call to > geterrmessage and extranct the message from the returned STRSXP). > > luke > > > extern void R_SetErrorHook(void (*)(SEXP, char *)); > > > > void > > my_ErrorHook(SEXP call, char *message) > > { > > > > /* > > etc; e.g., cache message, perhaps reset error hook (hook is > > removed after error; nested R-level try() may mean multiple > > errors per R_tryEval? > > */ > > > > } > > > > and then > > > > ... > > > > R_SetErrorHook( my_ErrorHook ); > > PROTECT(value = R_tryEval( expr, env, errorOccurred )); > > if( *errorOccurred ) { > > /* etc, e.g., retrieve error message(s) from cache */ > > } > > /* > > hmm, maybe R_SetErrorHook needs to be cleared here, or at > > least replaced with a no-op? > > */ > > ... > > > > This is an R-devel question, not R-help. > > > > Martin > > > > "Jorge W. Cardoso" <[EMAIL PROTECTED]> writes: > >> I'm writing a C++ application using R-embedding to do some > >> forecast process. > >> > >> I also use R_tryEval instead of R_Eval to run my R-script, > >> so that in case of error I know exactly in which line number > >> was the last error. > >> > >> In particular, from time in time y get some error messages > >> refering an exceptional condition in the arima model. > >> > >> I want to catch these error messages from de C code > >> (or at least the code error number) to take some > >> corrective actions. > >> > >> Is there any way to do that ? > >> > >> Regards, > >> > >> Jorge W. Cardoso > >> > >> ______________________________________________ > >> R-help@r-project.org mailing list > >> https://stat.ethz.ch/mailman/listinfo/r-help > >> PLEASE do read the posting guide > >> http://www.R-project.org/posting-guide.html and provide commented, > >> minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.