diff --git a/ChangeLog b/ChangeLog index bace91147..5d6f2857d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2020-04-15 Kevin Ushey + + * inst/include/Rcpp/String.h: Avoid 'debug' namespace collisions + * inst/include/Rcpp/macros/debug.h: Idem + * inst/include/Rcpp/macros/macros.h: Idem + 2020-04-15 Uwe Korn * inst/include/Rcpp/DataFrame.h: Explicit call to scalar std::abs diff --git a/inst/include/Rcpp/String.h b/inst/include/Rcpp/String.h index d15accf28..4d8efe20b 100644 --- a/inst/include/Rcpp/String.h +++ b/inst/include/Rcpp/String.h @@ -29,10 +29,10 @@ #if RCPP_STRING_DEBUG_LEVEL > 0 #define RCPP_STRING_DEBUG_FORMAT "%40s:%4d " - #define RCPP_STRING_DEBUG(MSG) Rprintf(RCPP_STRING_DEBUG_FORMAT "%s\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG); - #define RCPP_STRING_DEBUG_1(fmt, MSG) Rprintf(RCPP_STRING_DEBUG_FORMAT fmt "\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG); - #define RCPP_STRING_DEBUG_2(fmt, M1, M2) Rprintf(RCPP_STRING_DEBUG_FORMAT fmt "\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2); - #define RCPP_STRING_DEBUG_3(fmt, M1, M2, M3) Rprintf(RCPP_STRING_DEBUG_FORMAT fmt "\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3); + #define RCPP_STRING_DEBUG(MSG) Rprintf(RCPP_STRING_DEBUG_FORMAT "%s\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG); + #define RCPP_STRING_DEBUG_1(fmt, MSG) Rprintf(RCPP_STRING_DEBUG_FORMAT fmt "\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG); + #define RCPP_STRING_DEBUG_2(fmt, M1, M2) Rprintf(RCPP_STRING_DEBUG_FORMAT fmt "\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2); + #define RCPP_STRING_DEBUG_3(fmt, M1, M2, M3) Rprintf(RCPP_STRING_DEBUG_FORMAT fmt "\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3); #else #define RCPP_STRING_DEBUG(MSG) #define RCPP_STRING_DEBUG_1(fmt, MSG) diff --git a/inst/include/Rcpp/exceptions.h b/inst/include/Rcpp/exceptions.h index 110b625c3..91e1f4b62 100644 --- a/inst/include/Rcpp/exceptions.h +++ b/inst/include/Rcpp/exceptions.h @@ -108,9 +108,9 @@ namespace Rcpp { // Variadic / code generated version of the warning and stop functions // can be found within the respective C++11 or C++98 exceptions.h - // included below + // included below. inline void warning(const std::string& message) { // #nocov start - Rf_warning(message.c_str()); + ::Rf_warning("%s", message.c_str()); } // #nocov end inline void NORET stop(const std::string& message) { // #nocov start diff --git a/inst/include/Rcpp/macros/debug.h b/inst/include/Rcpp/macros/debug.h index e82c9a68a..a6c96d77e 100644 --- a/inst/include/Rcpp/macros/debug.h +++ b/inst/include/Rcpp/macros/debug.h @@ -33,12 +33,12 @@ #if RCPP_DEBUG_LEVEL > 0 - #define RCPP_DEBUG( MSG ) Rprintf( "%40s:%4d %s\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG ) ; - #define RCPP_DEBUG_1( fmt, MSG ) Rprintf( "%40s:%4d " fmt "\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG ) ; - #define RCPP_DEBUG_2( fmt, M1, M2 ) Rprintf( "%40s:%4d " fmt "\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2 ) ; - #define RCPP_DEBUG_3( fmt, M1, M2, M3 ) Rprintf( "%40s:%4d " fmt "\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3) ; - #define RCPP_DEBUG_4( fmt, M1, M2, M3, M4 ) Rprintf( "%40s:%4d " fmt "\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3, M4) ; - #define RCPP_DEBUG_5( fmt, M1, M2, M3, M4, M5 ) Rprintf( "%40s:%4d " fmt "\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3, M4, M5) ; + #define RCPP_DEBUG( MSG ) Rprintf( "%40s:%4d %s\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG ) ; + #define RCPP_DEBUG_1( fmt, MSG ) Rprintf( "%40s:%4d " fmt "\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG ) ; + #define RCPP_DEBUG_2( fmt, M1, M2 ) Rprintf( "%40s:%4d " fmt "\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2 ) ; + #define RCPP_DEBUG_3( fmt, M1, M2, M3 ) Rprintf( "%40s:%4d " fmt "\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3) ; + #define RCPP_DEBUG_4( fmt, M1, M2, M3, M4 ) Rprintf( "%40s:%4d " fmt "\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3, M4) ; + #define RCPP_DEBUG_5( fmt, M1, M2, M3, M4, M5 ) Rprintf( "%40s:%4d " fmt "\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3, M4, M5) ; #else #define RCPP_DEBUG( MSG ) #define RCPP_DEBUG_1( fmt, MSG ) @@ -52,49 +52,49 @@ #define RCPP_DEBUG_MODULE( MSG ) { \ Rcpp::Module * mod__ = getCurrentScope() ; \ if( mod__ ){ \ - Rprintf( "[module (%s) <%p> ] %40s:%4d %s\n" , mod__->name.c_str(), mod__, ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG ) ;\ + Rprintf( "[module (%s) <%p> ] %40s:%4d %s\n" , mod__->name.c_str(), mod__, ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG ) ;\ } else { \ - Rprintf( "[module () ] %40s:%4d %s\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG ) ; \ + Rprintf( "[module () ] %40s:%4d %s\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG ) ; \ } \ } #define RCPP_DEBUG_MODULE_1( fmt, MSG ) { \ Rcpp::Module * mod__ = getCurrentScope() ; \ if( mod__ ){ \ - Rprintf( "[module (%s) <%p> ] %40s:%4d " fmt "\n" , mod__->name.c_str(), mod__, ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG ) ;\ + Rprintf( "[module (%s) <%p> ] %40s:%4d " fmt "\n" , mod__->name.c_str(), mod__, ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG ) ;\ } else { \ - Rprintf( "[module () ] %40s:%4d " fmt "\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG ) ; \ + Rprintf( "[module () ] %40s:%4d " fmt "\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG ) ; \ } \ } #define RCPP_DEBUG_MODULE_2( fmt, M1, M2 ) { \ Rcpp::Module * mod__ = getCurrentScope() ; \ if( mod__ ){ \ - Rprintf( "[module (%s) <%p> ] %40s:%4d " fmt "\n" , mod__->name.c_str(), mod__, ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2 ) ;\ + Rprintf( "[module (%s) <%p> ] %40s:%4d " fmt "\n" , mod__->name.c_str(), mod__, ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2 ) ;\ } else { \ - Rprintf( "[module () ] %40s:%4d " fmt "\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2 ) ; \ + Rprintf( "[module () ] %40s:%4d " fmt "\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2 ) ; \ } \ } #define RCPP_DEBUG_MODULE_3( fmt, M1, M2, M3 ) { \ Rcpp::Module * mod__ = getCurrentScope() ; \ if( mod__ ){ \ - Rprintf( "[module (%s) <%p> ] %40s:%4d " fmt "\n" , mod__->name.c_str(), mod__, ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3 ) ;\ + Rprintf( "[module (%s) <%p> ] %40s:%4d " fmt "\n" , mod__->name.c_str(), mod__, ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3 ) ;\ } else { \ - Rprintf( "[module () ] %40s:%4d " fmt "\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3 ) ; \ + Rprintf( "[module () ] %40s:%4d " fmt "\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3 ) ; \ } \ } #define RCPP_DEBUG_MODULE_4( fmt, M1, M2, M3, M4 ) { \ Rcpp::Module * mod__ = getCurrentScope() ; \ if( mod__ ) { \ - Rprintf( "[module (%s) <%p> ] %40s:%4d " fmt "\n" , mod__->name.c_str(), mod__, ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3, M4 ) ;\ + Rprintf( "[module (%s) <%p> ] %40s:%4d " fmt "\n" , mod__->name.c_str(), mod__, ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3, M4 ) ;\ } else { \ - Rprintf( "[module () ] %40s:%4d " fmt "\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3, M4 ) ; \ + Rprintf( "[module () ] %40s:%4d " fmt "\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3, M4 ) ; \ } \ } #define RCPP_DEBUG_MODULE_5( fmt, M1, M2, M3, M4, M5 ) { \ Rcpp::Module * mod__ = getCurrentScope() ; \ if( mod__ ){ \ - Rprintf( "[module (%s) <%p> ] %40s:%4d " fmt "\n" , mod__->name.c_str(), mod__, ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3, M4, M5 ) ;\ + Rprintf( "[module (%s) <%p> ] %40s:%4d " fmt "\n" , mod__->name.c_str(), mod__, ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3, M4, M5 ) ;\ } else { \ - Rprintf( "[module () ] %40s:%4d " fmt "\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3, M4, M5 ) ; \ + Rprintf( "[module () ] %40s:%4d " fmt "\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3, M4, M5 ) ; \ } \ } #else diff --git a/inst/include/Rcpp/macros/macros.h b/inst/include/Rcpp/macros/macros.h index 12bd2d6b4..f3244e1c0 100644 --- a/inst/include/Rcpp/macros/macros.h +++ b/inst/include/Rcpp/macros/macros.h @@ -25,6 +25,7 @@ #include namespace Rcpp { +namespace internal { namespace debug { inline std::string short_file_name(const char* file) @@ -37,6 +38,7 @@ inline std::string short_file_name(const char* file) } } // namespace debug +} // namespace internal } // namespace Rcpp #define RCPP_DECORATE(__FUN__) __FUN__##__rcpp__wrapper__