[R-pkg-devel] R_registerRoutines, etc.

Rolf Turner r.turner at auckland.ac.nz
Mon Apr 24 00:45:41 CEST 2017


On 24/04/17 10:31, Dirk Eddelbuettel wrote:

>
> On 24 April 2017 at 10:18, Rolf Turner wrote:
> | One more (I hope it's the last!) question:
> |
> | One of my subroutines has an argument of type *logical*.  There is no
> | logical type in C.  So, since I am perforce using C-speak, I cannot
> | change "void *" to "void logical".
> |
> | I have a (very vague) understanding that in C one uses variables of int
> | type (taking the values 0, for FALSE, and 1, for TRUE) as logical variables.
> |
> | On that understanding I took a punt and replaced "void *" by "int *" for
> | the logical type variable.  The package built and passed
> |
> |      "R CMD check --as-cran"
> |
> | so it seems that this is OK.  Is this the Right Thing To Do?  Are there
> | any (obvious?) lurking perils?
>
> I think you are allowed to use C99 [1] which has it -- see eg
>
> http://stackoverflow.com/questions/4159713/how-to-use-boolean-datatype-in-c
>
> Dirk
>
> [1] Section 1.6.4 opems with
>
>     1.6.4 Portable C and C++ code
>     -----------------------------
>
>     Writing portable C and C++ code is mainly a matter of observing the
>     standards (C99, C++98 or where declared C++11/14) and testing that
>     extensions (such as POSIX functions) are supported.

Ah, but I'm *not* using C at all, I'm using Fortran.  So I think that 
raising the possibility of using C99 is a communist fish[1].  I just 
want to make sure that my (modified) init.c is syntactically correct and 
robust for implementing the registration of my *Fortran* routines.

cheers,

Rolf

[1] Red herring.

-- 
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276



More information about the R-package-devel mailing list