我正在尝试为R创建一个小扩展,以便在R提示符上嵌入当前时间:https://github.com/musically-ut/extPrompt
事情似乎总体上起作用,但是R CMD check .
发出警告:
文件'[截断] .. Rcheck / extPrompt / libs / extPrompt.so': 找到对R的非API调用:'ptr_R_ReadConsole'
编译代码不应该调用R中的非API入口点。
有关文件是这样的:https://github.com/musically-ut/extPrompt/blob/master/src/extPrompt.c并且发生在第38行,我想。
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);
}
我正在尝试进行R_ReadConsole
API调用。但是,由于不同的插件(如我的)已经可以覆盖它,我不想直接调用R_ReadConsole
但是之前位于ptr_R_ReadConsole
的函数。
这是对API的错误使用吗?
答案 0 :(得分:0)
错误使用API - 是的。由于R CMD检查是有道理的 你这是一个问题,这是正式的问题。这是没有的 如果该包适用于您及其任何用户,那么结果如此 该软件包不在CRAN上托管。但是,使用此符号 您的代码可能无法在所有平台上运行,并且无法保证 在将来工作(但可能会!)。