[R-pkg-devel] Including "Rmath.h" in C code for an R package

Gregory Raskind gr@@k|nd1 @end|ng |rom gm@||@com
Mon Jun 3 16:57:25 CEST 2024


Thank you for the suggestion! It looks like that caused problems with other
parts of the code, so I just added these couple of lines after the import
to avoid the beta remaps:

#ifdef beta
#undef beta
#endif

On Mon, Jun 3, 2024 at 5:56 AM Duncan Murdoch <murdoch.duncan using gmail.com>
wrote:

> On 2024-06-02 7:39 p.m., Iris Simmons wrote:
> > To avoid the remapping of beta to Rf_beta, you should
> > define R_NO_REMAP_RMATH before you include Rmath:
> >
> > #define R_NO_REMAP_RMATH
> > #include <Rmath.h>
>
> ... and then remember to include the "Rf_" prefix on the routines that
> you do want to use.
>
> Duncan Murdoch
>
> >
> > On Sun, Jun 2, 2024, 19:33 Gregory Raskind <graskind1 using gmail.com> wrote:
> >
> >> Hi,
> >>
> >> I'm extending an R package that uses the R C API directly. I'd like to
> use
> >> some distribution functions, so I included the "Rmath.h" header. The
> issue
> >> is that this introduces macros that have unintended consequences for the
> >> code. For example, I have a local variable named "beta", which is
> expanded
> >> to "Rf_beta".
> >>
> >> Is there a way of including the "Rmath.h" header without applying the
> >> macros to my code? E.g. if I want to use the beta function, I would use
> it
> >> with "Rf_beta(a,b)", but "beta" would remain my local variable.
> >>
> >> Thanks for your time!
> >>
> >> Best,
> >> Greg
> >>
> >>          [[alternative HTML version deleted]]
> >>
> >> ______________________________________________
> >> R-package-devel using r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-package-devel
> >>
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-package-devel using r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-package-devel
>
>

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list