Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R_CMethodDef Declaration #1

Closed
wrathematics opened this issue Nov 14, 2018 · 1 comment
Closed

R_CMethodDef Declaration #1

wrathematics opened this issue Nov 14, 2018 · 1 comment

Comments

@wrathematics
Copy link

In src/init.c, you don't specify the fourth field of your R_CMethodDef declaration. If you compile with -Wmissing-field-initializers in gcc, you will see the warning:

init.c:18:5: warning: missing initializer for field ‘types’ of ‘R_CMethodDef {aka const struct <anonymous>}’ [-Wmissing-field-initializers]
     {"C_polygauss", (DL_FUNC) &C_polygauss, 13},
     ^
In file included from init.c:12:0:
/usr/share/R/include/R_ext/Rdynload.h:55:31: note: ‘types’ declared here
     R_NativePrimitiveArgType *types;
                               ^~~~~
init.c:19:5: warning: missing initializer for field ‘types’ of ‘R_CMethodDef {aka const struct <anonymous>}’ [-Wmissing-field-initializers]
     {NULL, NULL, 0}
     ^
In file included from init.c:12:0:
/usr/share/R/include/R_ext/Rdynload.h:55:31: note: ‘types’ declared here
     R_NativePrimitiveArgType *types;
                               ^~~~~

You can see what it's complaining about here https://cran.r-project.org/doc/manuals/R-exts.html#Registering-native-routines (see their myC_t bit). It's probably not dangerous, but it's also easy enough to fix. Just change your CEntries line to this:

static const R_CMethodDef CEntries[] = {
    {"C_polygauss", (DL_FUNC) &C_polygauss, 13, NULL},
    {NULL, NULL, 0, NULL}
};

It's probably not dangerous though, so feel free to close the issue if you prefer.

@bastistician
Copy link
Owner

Thanks for testing! I will add the types declaration.

I had based my init file on

tools::package_native_routine_registration_skeleton(".", character_only = FALSE)

which simply omits the types argument (as do most base R packages).

Searching for R_NativePrimitiveArgType on GitHub I did find some R packages which use proper code, for example, cluster, potts, cheddar, earth. polyCub will be among these soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants