From therneau at mayo.edu  Fri Dec 29 19:13:58 2017
From: therneau at mayo.edu (Therneau, Terry M., Ph.D.)
Date: Fri, 29 Dec 2017 12:13:58 -0600
Subject: [Rd] winbuilder warning message wrt function pointers
In-Reply-To: <CAF8bMcaxsFdFPKbEL94jjadZtGJY6Bw_C9RLt18yqvbcrsQFpQ@mail.gmail.com>
References: <375144$8j4pe9@ironport10.mayo.edu>
 <CAF8bMcbWjrNX4uBKxDd__s9HvxZ+Xkesyk5odegO8CaUxhWqtw@mail.gmail.com>
 <CAF8bMcaxsFdFPKbEL94jjadZtGJY6Bw_C9RLt18yqvbcrsQFpQ@mail.gmail.com>
Message-ID: <375144$8j7b3u@ironport10.mayo.edu>

Bill,
 ? That's a very nice solution.? It is both cleaner looking and preferable to track R's .h 
files.
However, some of my routines don't have void * as the return type (two are int *), and 
Rdynload has

 ?? typedef void * (*DL_FUNC)();

Will this untruth mess anything up?

Terry T.

On 12/29/2017 10:52 AM, William Dunlap wrote:
> And remove the cast on the return value of R_GETCCallable.? And check
> that your function is found before using it.
>
> #include <R.h>
> #include <Rinternals.h>
> #include <R_ext/Rdynload.h>
>
> void bdsmatrix_prod4(int nrow,? ? int nblock,? ?int *bsize,
> ? ? ? ? ? ? ? ? ? ? double *bmat, double *rmat,
> ? ? ? ? ? ? ? ? ? ? int nfrail,? ?double *y) {
> ? ? DL_FUNC fun = NULL;
> ? ? if (fun==NULL) {
> ? ? ? ? fun = R_GetCCallable("bdsmatrix", "bdsmatrix_prod4");
> ? ? }
> ? ? if (fun==NULL) {
> ? ? ? ? Rf_error("Cannot find C function 'bdsmatrix_prod4' in library 
> 'bdsmatrix.{so,dll}'");
> ? ? }
> ? ? fun(nrow, nblock, bsize, bmat, rmat, nfrail, y);
> ? ? }
>
>
>
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com <http://tibco.com>
>
> On Fri, Dec 29, 2017 at 8:48 AM, William Dunlap <wdunlap at tibco.com 
> <mailto:wdunlap at tibco.com>> wrote:
>
>     Try changing
>     ??static void (*fun)() = NULL;
>     to
>     ? DL_FUNC fun = NULL;
>
>     Bill Dunlap
>     TIBCO Software
>     wdunlap tibco.com <http://tibco.com>
>
>     On Fri, Dec 29, 2017 at 5:14 AM, Therneau, Terry M., Ph.D. <therneau at mayo.edu
>     <mailto:therneau at mayo.edu>> wrote:
>
>         I've recently updated the coxme package, which calls internal routines from the
>         bdsmatrix package.? (It is in fact mentioned as an example of this in the
>         Extensions manual.)
>         The call connections are a blocks like this, one for each of the 9 called C
>         routines.
>
>         void bdsmatrix_prod4(int nrow,??? int nblock, int *bsize,
>         ??????????????????? double *bmat, double *rmat,
>         ??????????????????? int nfrail,?? double *y) {
>         ??? static void (*fun)() = NULL;
>         ??? if (fun==NULL)
>         ??? fun = (void (*)) R_GetCCallable("bdsmatrix", "bdsmatrix_prod4");
>         ??? fun(nrow, nblock, bsize, bmat, rmat, nfrail, y);
>         ??? }
>
>         ..
>
>         The winbuilder run is flagging all of these with
>
>         bdsmatrix_stub.h:22:6: warning: ISO C forbids assignment between function
>         pointer and 'void *' [-Wpedantic]
>         ? fun = (void (*)) R_GetCCallable("bdsmatrix", "bdsmatrix_prod4");
>
>         Ignore?? Or should these lines have been written in a different way?
>
>         Terry T.
>
>         ______________________________________________
>         R-devel at r-project.org <mailto:R-devel at r-project.org> mailing list
>         https://stat.ethz.ch/mailman/listinfo/r-devel
>         <https://stat.ethz.ch/mailman/listinfo/r-devel>
>
>
>


	[[alternative HTML version deleted]]



[Rd] winbuilder warning message wrt function pointers
Therneau, Terry M., Ph.D.