Le 15/06/10 17:27, Dominick Samperi a écrit :
This code seems simple enough (from cxxPack)...

RcppExport SEXP testBankOpen(SEXP name, SEXP id, SEXP balance) {
     BEGIN_RCPP
     BankAccount *p = new BankAccount(Rcpp::as<std::string>(name),
                      Rcpp::as<int>(id),
                      Rcpp::as<double>(balance));
     Rcpp::XPtr<BankAccount> xp(p, true);
     return xp;
     END_RCPP
}

Yet I get this from the Sun/Solaris compiler;
>
"/home/ripley/R/Lib32/Rcpp/include/Rcpp/XPtr.h", line 46: Warning:
m_sexp hides Rcpp::RObject::m_sexp.
"testBankAccount.cpp", line 35: Where: While instantiating
"Rcpp::XPtr<BankAccount>::XPtr(SEXPREC*, SEXPREC*, SEXPREC*)".
"testBankAccount.cpp", line 35: Where: Instantiated from non-template code.
"/home/ripley/R/Lib32/Rcpp/include/Rcpp/XPtr.h", line 180: Warning
(Anachronism): Formal argument fun of type extern "C" void(*)(SEXPREC*)
in call to R_RegisterCFinalizerEx(SEXPREC*, extern "C"
void(*)(SEXPREC*), Rboolean) is being passed void(*)(SEXPREC*).
"/home/ripley/R/Lib32/Rcpp/include/Rcpp/XPtr.h", line 174: Where: While
instantiating "Rcpp::XPtr<BankAccount>::setDeleteFinalizer()".
"/home/ripley/R/Lib32/Rcpp/include/Rcpp/XPtr.h", line 174: Where:
Instantiated from Rcpp::XPtr<BankAccount>::XPtr(BankAccount*, bool,
SEXPREC*, SEXPREC*).
"testBankAccount.cpp", line 25: Where: Instantiated from non-template code.

This is just a warning. The problem is that a function with C linkage is expected, see the file Rinternals.h :

typedef void (*R_CFinalizer_t)(SEXP);
void R_RegisterFinalizer(SEXP s, SEXP fun);
void R_RegisterCFinalizer(SEXP s, R_CFinalizer_t fun);
void R_RegisterFinalizerEx(SEXP s, SEXP fun, Rboolean onexit);
void R_RegisterCFinalizerEx(SEXP s, R_CFinalizer_t fun, Rboolean onexit);

this is enclosed in a extern "C" so suncc adds the extern "C" to the R_CFinalizer_t type, and we cannot provide a function with C linkage because we generate it from a template.

Not sure what the right fix is, and not sure this can be fixed at the Rcpp level, and something in R might be required to allow registration of finalizers with C++ linkage. OTOH, this is just a warning.

The same compiler warns when I wrap a std::vector<double>:

"/home/ripley/R/Lib32/Rcpp/include/Rcpp/traits/is_convertible.h", line
40: Warning: A non-POD object of type "std::vector<double>" passed as a
variable argument to function "static
Rcpp::traits::is_convertible<std::vector<double>, SEXPREC*>::Test(...)".
"/home/ripley/R/Lib32/Rcpp/include/Rcpp/internal/wrap.h", line 510:
Where: While specializing
"Rcpp::traits::is_convertible<std::vector<double>, SEXPREC*>".
"/home/ripley/R/Lib32/Rcpp/include/Rcpp/internal/wrap.h", line 510:
Where: Instantiated from
Rcpp::internal::wrap_dispatch_unknown_importable<std::vector<double>>(const
std::vector<double>&, Rcpp::traits::integral_constant<bool, 0>).
"/home/ripley/R/Lib32/Rcpp/include/Rcpp/internal/wrap.h", line 527:
Where: Instantiated from
Rcpp::internal::wrap_dispatch<std::vector<double>>(const
std::vector<double>&, Rcpp::traits::wrap_type_unknown_tag).
"/home/ripley/R/Lib32/Rcpp/include/Rcpp/internal/wrap.h", line 624:
Where: Instantiated from Rcpp::wrap<std::vector<double>>(const
std::vector<double>&).
"testFFT.cpp", line 29: Where: Instantiated from non-template code.

This is suncc not reacting well to SFINAE. Apparently it does not know we are not actually calling Test(...), as the sizeof trick is used.

This again is just a warning. I don't know of another way to do this. tr1 has the is_convertible class built in, but I have no idea if the stl implementation in use has tr1.

In our adventures to make Rcpp work on solaris/suncc, we recorded these findings here: http://rwiki.sciviews.org/doku.php?id=developers:rcpp:solaris

The cran checks for your package indicates that it passes with just a NOTE, which is fine.

Romain

Odd thing about the last message is that there are two lines that do
exactly the same thing (wrap a std::vector<double>) but
the compiler issues a warning about only one of them.
>
Ideas?

Thanks,
Dominick

--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/98Uf7u : Rcpp 0.8.1
|- http://bit.ly/c6YnCi : graph gallery collage
`- http://bit.ly/bZ7ltC : inline 0.3.5

_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to