Skip to content

avoid collisions with debug namespace #1071

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

Merged
merged 2 commits into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2020-04-15 Kevin Ushey <kevinushey@gmail.com>

* 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 <mail@uwekorn.com>

* inst/include/Rcpp/DataFrame.h: Explicit call to scalar std::abs
Expand Down
8 changes: 4 additions & 4 deletions inst/include/Rcpp/String.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions inst/include/Rcpp/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 18 additions & 18 deletions inst/include/Rcpp/macros/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions inst/include/Rcpp/macros/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <string>

namespace Rcpp {
namespace internal {
namespace debug {

inline std::string short_file_name(const char* file)
Expand All @@ -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__
Expand Down