Utkarsh Upadhyay
2014-Oct-27 14:15 UTC
[Rd] Calling the original function after tweaking arguments is an incorrect use of the R-API?
Hi, I am trying to create a small extension for R here for embedding the current time on the R prompt:https://github.com/musically-ut/extPrompt Things seem to be working overall, but R CMD check . raised a warning: File '[truncated]..Rcheck/extPrompt/libs/extPrompt.so?: Found non-API call> to R: ?ptr_R_ReadConsole?Compiled code should not call non-API entry points in R. The concerned file is this: https://github.com/musically-ut/extPrompt/blob/master/src/extPrompt.c and occurs on line 38, I think. void extPrompt() {> // Initialize the plugin by replacing the R_ReadConsole function > old_R_ReadConsole = ptr_R_ReadConsole; > ptr_R_ReadConsole = extPrompt_ReadConsole; > // ... > } > int extPrompt_ReadConsole(const char *old_prompt, unsigned char *buf, int > len, > int addtohistory) { > // ... > // Call the old function with the `new_prompt` > return (*old_R_ReadConsole)(new_prompt, buf, len, addtohistory); > }I am trying to make the R_ReadConsole API call. However, since a different plugin (like mine) could have overridden it already, I do not want to directly invoke R_ReadConsole but the function which previously was at ptr_R_ReadConsole. Is this an incorrect use of the API? Also, any other feedback on the plugin is also welcome. Thanks. ~ ut PS: I had posted this question on StackOverflow a while back: http://stackoverflow.com/questions/26335571/is-this-an-incorrect-use-of-the-r-api If I receive a response, I will update the question with the appropriate answer. [[alternative HTML version deleted]]