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

Declare (or replace) C++11 functions #10

Open
jameshiebert opened this issue Sep 18, 2016 · 0 comments
Open

Declare (or replace) C++11 functions #10

jameshiebert opened this issue Sep 18, 2016 · 0 comments

Comments

@jameshiebert
Copy link
Contributor

From Professor Brian D. Ripley:

[climdex.pcic] use[s] functions/macros which are not part of C++98: see the logs
at http://www.stats.ox.ac.uk/pub/bdr/C++Solaris .

Functions

 erf expm1 floorf fmin fminf fmax lgamma lround loglp round snprintf
 strcasecmp trunc

were introduced in C99 and so are part of C++11 but not C++98 and the
Solaris C++ compiler does not provide prototypes for them: unfortunately
g++ does not warn of this. (R is currently including from R.h legacy
headers such as math.h to work around this, but that will be changed
for R 3.4.0.)

R's Rmath.h provides fmax2 fmin2 fround ftrunc gammafn : please use
them as appropriate. Also, erf can be replaced by a call to R's pnorm (the
translation is in the R help file for pnorm).

C++98's floor has a method for floats, so floorf is not needed in C++ .

Constants M_LN2 (gmp), M_SQRT2 (mixAK) and M_PI4 (simLife) are not
C++98. You can get them by including Rmath.h (or copy them from there).

For wtcrsk, isnan is not C++98, but R provides ISNAN for use in C++.

For SSN, strdup is a GNU/POSIX extension to C and not in any C++
standard hence not declared in according to the standard.
Substitutes are widely available: we suggest you use one.

For the rest, the best solution would seem to be to declare that C++11
is used: see 'Writing R Extensions'.

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

1 participant