[Rcpp-devel] RcppArmadillo fails on FreeBSD

Dirk Eddelbuettel edd at debian.org
Mon May 30 18:21:00 CEST 2011


On 30 May 2011 at 17:21, Rainer Hurling wrote:
| > I do not understand what you are asking: "as meant in RcppArmadilloConfig" ?
| > Neither Romain, Doug nor I use a *BSD variant (if we ignore OS X as a BSD-derivative).
| > So nothing in RcppArmadillo explicitly enables or disables *BSD.
| 
| Thanks for answering. Sorry for my bad english and the misunderstanding. 
| I am not a developer so the following is just a wild guess:
| 
| In FreeBSD there is a function snprintf in stdio of libc. I was 
| wondering if this could be the function, which RcppArmadillo would 
| expect to find (on linux etc.) at std:snprintf?
| 
| If yes, is there some chance to use this type of snprintf on FreeBSD 
| systems? Or is my below patch ok and there is no problem not using 
| snprintf (on FreeBSD) at all?
| 
| Hope this is not totally nonsense.

Between you and me, somebody is confused.

snprintf is a standard C library function going (IIRC) back to Kernighan and
Ritchie. My system's manual page shows

       int snprintf(char *str, size_t size, const char *format, ...);

which is the same as what you quoted:

       int snprintf(char * restrict str, size_t size, const char * restrict format, ...);

apart from the sole difference of 'restrict' which I've never seen before.

So per se, we should not need anything special to use snprintf.  Can you try
something like this on your box, please?

edd at max:/tmp$ gcc -Wall -o rainer rainer.c 
edd at max:/tmp$ ./rainer 
Char vector is now [Hello, world]
edd at max:/tmp$ cat rainer.c

#include <stdio.h>

int main(void) {
    char foo[32];
    snprintf(foo, 31, "Hello, world");
    printf("Char vector is now [%s]\n", foo);
    return(0);
}
edd at max:/tmp$ 

We may have turned snprintf off for you by accident, but following your patch
we should now be good.

Unless I am totally undercaffeinated and missing something here.

Dirk

| > You have to tell us what works or doesn't. We cannot test or develop changes
| > for *BSD.
| >
| > | Many thanks in advance,
| > | Rainer Hurling
| > |
| > | ----------------------------------------------------------------------
| > | --- inst/include/RcppArmadilloConfig.h.origin	2011-05-27 17:18:47.000000000 +0200
| > | +++ inst/include/RcppArmadilloConfig.h	2011-05-30 13:53:25.000000000 +0200
| > | @@ -37,7 +37,7 @@
| > |
| > |
| > |  /* TODO: we might need to undef this on other platforms as well */
| > | -#if defined(__GNUC__)&&  defined(_WIN64)
| > | +#if defined(__GNUC__)&&  defined(_WIN64) || defined(__FreeBSD__)
| > |  #undef ARMA_HAVE_STD_SNPRINTF
| > |  #endif
| >
| > That patch looks fine to me and would presumabky play nicely with Armadillo
| > as the change would be solely at our level.
| >
| > I'll apply it it now, so 0.2.22 will have it.
| 
| Thanks for including the patch,
| Rainer
| 
| > Dirk

-- 
Gauss once played himself in a zero-sum game and won $50.
                      -- #11 at http://www.gaussfacts.com


More information about the Rcpp-devel mailing list