diff --git a/ChangeLog b/ChangeLog index e3cf3797a..67f9bca06 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,12 @@ * README.md: Remove link references to StackOverflow * inst/NEWS.Rd: Idem + * inst/include/Rcpp/Module.h (S4_CppOverloadedMethods): Add cast to int + to avoid warnings under 'clang++-17 -Wconversion -Wno-sign-conversion' + * inst/include/Rcpp/vector/Vector.h (Vector): Idem + * inst/include/Rcpp/module/class.h: Switch variable to size_t to avoid + to avoid warnings under 'clang++-17 -Wconversion -Wno-sign-conversion' + * inst/tinytest/testRcppClass/src/init.c: Add void to signature 2024-05-26 Dirk Eddelbuettel diff --git a/inst/include/Rcpp/Module.h b/inst/include/Rcpp/Module.h index 02a242f87..cdb12d4d0 100644 --- a/inst/include/Rcpp/Module.h +++ b/inst/include/Rcpp/Module.h @@ -1,5 +1,4 @@ -// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- -// + // Module.h: Rcpp R/C++ interface class library -- Rcpp modules // // Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois @@ -105,13 +104,13 @@ namespace Rcpp { class CppFunctionN : public CppFunction { public: CppFunctionN(RESULT_TYPE (*fun)(T...), const char* docstring = 0) : CppFunction(docstring), ptr_fun(fun) {} - + SEXP operator()(SEXP* args) { BEGIN_RCPP return call(ptr_fun, args); END_RCPP } - + inline int nargs() { return sizeof...(T); } inline void signature(std::string& s, const char* name) { Rcpp::signature(s, name); } inline DL_FUNC get_function_ptr() { return (DL_FUNC)ptr_fun; } @@ -119,7 +118,7 @@ namespace Rcpp { private: RESULT_TYPE (*ptr_fun)(T...); }; - + template class CppFunction_WithFormalsN : public CppFunctionN { public: @@ -351,7 +350,7 @@ namespace Rcpp{ typedef std::vector vec_signed_method ; S4_CppOverloadedMethods( vec_signed_method* m, const XP_Class& class_xp, const char* name, std::string& buffer ) : Reference( "C++OverloadedMethods" ){ - int n = m->size() ; + int n = static_cast(m->size()) ; Rcpp::LogicalVector voidness(n), constness(n) ; Rcpp::CharacterVector docstrings(n), signatures(n) ; Rcpp::IntegerVector nargs(n) ; @@ -405,10 +404,10 @@ namespace Rcpp{ private: Method met; }; - + template using CppMethodN = CppMethodImplN; - + template using const_CppMethodN = CppMethodImplN; @@ -435,10 +434,10 @@ namespace Rcpp{ private: Method met; }; - + template using Pointer_CppMethodN = Pointer_CppMethodImplN; - + template using Const_Pointer_CppMethodN = Pointer_CppMethodImplN; #else @@ -661,4 +660,3 @@ static VARIABLE_IS_NOT_USED SEXP moduleSym = NULL; Rcpp_fast_eval( __load_module_call__, R_GlobalEnv ); #endif - diff --git a/inst/include/Rcpp/module/class.h b/inst/include/Rcpp/module/class.h index 4ef998962..d617f164e 100644 --- a/inst/include/Rcpp/module/class.h +++ b/inst/include/Rcpp/module/class.h @@ -1,5 +1,4 @@ -// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- -// + // class.h: Rcpp R/C++ interface class library -- Rcpp modules // // Copyright (C) 2012 - 2013 Dirk Eddelbuettel and Romain Francois @@ -136,8 +135,8 @@ SEXP newInstance( SEXP* args, int nargs ){ BEGIN_RCPP signed_constructor_class* p ; - int n = constructors.size() ; - for( int i=0; ivalid)(args, nargs) ; if( ok ){ @@ -148,7 +147,7 @@ signed_factory_class* pfact ; n = factories.size() ; - for( int i=0; ivalid)(args, nargs) ; if( ok ){ @@ -162,15 +161,15 @@ } bool has_default_constructor(){ - int n = constructors.size() ; + size_t n = constructors.size() ; signed_constructor_class* p ; - for( int i=0; inargs() == 0 ) return true ; } n = factories.size() ; signed_factory_class* pfact ; - for( int i=0; inargs() == 0 ) return true ; } @@ -182,10 +181,10 @@ vec_signed_method* mets = reinterpret_cast< vec_signed_method* >( R_ExternalPtrAddr( method_xp ) ) ; typename vec_signed_method::iterator it = mets->begin() ; - int n = mets->size() ; + size_t n = mets->size() ; method_class* m = 0 ; bool ok = false ; - for( int i=0; ivalid )( args, nargs) ){ m = (*it)->method ; ok = true ; @@ -209,10 +208,10 @@ vec_signed_method* mets = reinterpret_cast< vec_signed_method* >( R_ExternalPtrAddr( method_xp ) ) ; typename vec_signed_method::iterator it = mets->begin() ; - int n = mets->size() ; + size_t n = mets->size() ; method_class* m = 0 ; bool ok = false ; - for( int i=0; ivalid )( args, nargs) ){ m = (*it)->method ; ok = true ; @@ -231,10 +230,10 @@ vec_signed_method* mets = reinterpret_cast< vec_signed_method* >( R_ExternalPtrAddr( method_xp ) ) ; typename vec_signed_method::iterator it = mets->begin() ; - int n = mets->size() ; + size_t n = mets->size() ; method_class* m = 0 ; bool ok = false ; - for( int i=0; ivalid )( args, nargs) ){ m = (*it)->method ; ok = true ; @@ -326,19 +325,19 @@ } Rcpp::CharacterVector method_names(){ - int n = 0 ; - int s = vec_methods.size() ; + size_t n = 0 ; + size_t s = vec_methods.size() ; typename map_vec_signed_method::iterator it = vec_methods.begin( ) ; - for( int i=0; isecond)->size() ; } Rcpp::CharacterVector out(n) ; it = vec_methods.begin() ; - int k = 0 ; - for( int i=0; isecond)->size() ; std::string name = it->first ; - for( int j=0; jsecond)->size() ; } Rcpp::CharacterVector mnames(n) ; Rcpp::IntegerVector res(n) ; it = vec_methods.begin() ; - int k = 0 ; - for( int i=0; isecond)->size() ; std::string name = it->first ; typename vec_signed_method::iterator m_it = (it->second)->begin() ; - for( int j=0; jnargs() ; } @@ -370,21 +369,21 @@ } Rcpp::LogicalVector methods_voidness(){ - int n = 0 ; - int s = vec_methods.size() ; + size_t n = 0 ; + size_t s = vec_methods.size() ; typename map_vec_signed_method::iterator it = vec_methods.begin( ) ; - for( int i=0; isecond)->size() ; } Rcpp::CharacterVector mnames(n) ; Rcpp::LogicalVector res(n) ; it = vec_methods.begin() ; - int k = 0 ; - for( int i=0; isecond)->size() ; std::string name = it->first ; typename vec_signed_method::iterator m_it = (it->second)->begin() ; - for( int j=0; jis_void() ; } @@ -395,21 +394,21 @@ Rcpp::CharacterVector property_names(){ - int n = properties.size() ; + size_t n = properties.size() ; Rcpp::CharacterVector out(n) ; typename PROPERTY_MAP::iterator it = properties.begin( ) ; - for( int i=0; ifirst ; } return out ; } Rcpp::List property_classes(){ - int n = properties.size() ; + size_t n = properties.size() ; Rcpp::CharacterVector pnames(n) ; Rcpp::List out(n) ; typename PROPERTY_MAP::iterator it = properties.begin( ) ; - for( int i=0; ifirst ; out[i] = it->second->get_class() ; } @@ -418,12 +417,12 @@ } Rcpp::CharacterVector complete(){ - int n = vec_methods.size() - specials ; - int ntotal = n + properties.size() ; + size_t n = vec_methods.size() - specials ; + size_t ntotal = n + properties.size() ; Rcpp::CharacterVector out(ntotal) ; typename map_vec_signed_method::iterator it = vec_methods.begin( ) ; std::string buffer ; - int i=0 ; + size_t i=0 ; for( ; ifirst ; if( buffer[0] == '[' ) continue ; @@ -459,11 +458,11 @@ Rcpp::List fields( const XP_Class& class_xp ){ - int n = properties.size() ; + size_t n = properties.size() ; Rcpp::CharacterVector pnames(n) ; Rcpp::List out(n) ; typename PROPERTY_MAP::iterator it = properties.begin( ) ; - for( int i=0; ifirst ; out[i] = S4_field( it->second, class_xp ) ; } @@ -476,12 +475,12 @@ #if RCPP_DEBUG_LEVEL > 0 Rf_PrintValue( class_xp ) ; #endif - int n = vec_methods.size() ; + size_t n = vec_methods.size() ; Rcpp::CharacterVector mnames(n) ; Rcpp::List res(n) ; typename map_vec_signed_method::iterator it = vec_methods.begin( ) ; vec_signed_method* v; - for( int i=0; ifirst ; v = it->second ; res[i] = S4_CppOverloadedMethods( v , class_xp, it->first.c_str(), buffer ) ; @@ -491,10 +490,10 @@ } Rcpp::List getConstructors( const XP_Class& class_xp, std::string& buffer){ - int n = constructors.size() ; + size_t n = constructors.size() ; Rcpp::List out(n) ; typename vec_signed_constructor::iterator it = constructors.begin( ) ; - for( int i=0; i( *it , class_xp, name, buffer ) ; } return out ; diff --git a/inst/include/Rcpp/vector/Vector.h b/inst/include/Rcpp/vector/Vector.h index 01505eb02..a287f3098 100644 --- a/inst/include/Rcpp/vector/Vector.h +++ b/inst/include/Rcpp/vector/Vector.h @@ -331,7 +331,7 @@ class Vector : } inline iterator begin() { return cache.get() ; } - inline iterator end() { return cache.get() + size() ; } + inline iterator end() { return cache.get() + static_cast(size()) ; } inline const_iterator begin() const{ return cache.get_const() ; } inline const_iterator end() const{ return cache.get_const() + size() ; } inline const_iterator cbegin() const{ return cache.get_const() ; } diff --git a/inst/tinytest/testRcppClass/src/init.c b/inst/tinytest/testRcppClass/src/init.c index 6dc74eb23..7e7715d0e 100644 --- a/inst/tinytest/testRcppClass/src/init.c +++ b/inst/tinytest/testRcppClass/src/init.c @@ -3,15 +3,15 @@ #include // for NULL #include -/* FIXME: +/* FIXME: Check these declarations against the C/Fortran source code. */ /* .Call calls */ -extern SEXP rcpp_hello_world_cpp(); -extern SEXP _rcpp_module_boot_NumEx(); -extern SEXP _rcpp_module_boot_RcppClassModule(); -extern SEXP _rcpp_module_boot_stdVector(); +extern SEXP rcpp_hello_world_cpp(void); +extern SEXP _rcpp_module_boot_NumEx(void); +extern SEXP _rcpp_module_boot_RcppClassModule(void); +extern SEXP _rcpp_module_boot_stdVector(void); static const R_CallMethodDef CallEntries[] = { {"rcpp_hello_world_cpp", (DL_FUNC) &rcpp_hello_world_cpp, 0},