1

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?

1 Answer 1

0

From the r-devel mailing list:

As for incorrectly using the API - yes. Since R CMD check is telling you this is a problem, it is officially a problem. This is of no consequence if the package works for you and any users of it, and the package is not to be hosted on CRAN. However, using this symbol in your code may not work on all platforms, and is not guaranteed to work in the future (but probably will!).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.