Skip to content

Commit 446c3ca

Browse files
authored
Merge pull request #1071 from RcppCore/bugfix/short-file-name-namespacing
avoid collisions with debug namespace
2 parents a80908f + 1ddbc9f commit 446c3ca

File tree

5 files changed

+32
-24
lines changed

5 files changed

+32
-24
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2020-04-15 Kevin Ushey <[email protected]>
2+
3+
* inst/include/Rcpp/String.h: Avoid 'debug' namespace collisions
4+
* inst/include/Rcpp/macros/debug.h: Idem
5+
* inst/include/Rcpp/macros/macros.h: Idem
6+
17
2020-04-15 Uwe Korn <[email protected]>
28

39
* inst/include/Rcpp/DataFrame.h: Explicit call to scalar std::abs

inst/include/Rcpp/String.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929

3030
#if RCPP_STRING_DEBUG_LEVEL > 0
3131
#define RCPP_STRING_DEBUG_FORMAT "%40s:%4d "
32-
#define RCPP_STRING_DEBUG(MSG) Rprintf(RCPP_STRING_DEBUG_FORMAT "%s\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG);
33-
#define RCPP_STRING_DEBUG_1(fmt, MSG) Rprintf(RCPP_STRING_DEBUG_FORMAT fmt "\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG);
34-
#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);
35-
#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);
32+
#define RCPP_STRING_DEBUG(MSG) Rprintf(RCPP_STRING_DEBUG_FORMAT "%s\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG);
33+
#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);
34+
#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);
35+
#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);
3636
#else
3737
#define RCPP_STRING_DEBUG(MSG)
3838
#define RCPP_STRING_DEBUG_1(fmt, MSG)

inst/include/Rcpp/exceptions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ namespace Rcpp {
108108

109109
// Variadic / code generated version of the warning and stop functions
110110
// can be found within the respective C++11 or C++98 exceptions.h
111-
// included below
111+
// included below.
112112
inline void warning(const std::string& message) { // #nocov start
113-
Rf_warning(message.c_str());
113+
::Rf_warning("%s", message.c_str());
114114
} // #nocov end
115115

116116
inline void NORET stop(const std::string& message) { // #nocov start

inst/include/Rcpp/macros/debug.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333

3434

3535
#if RCPP_DEBUG_LEVEL > 0
36-
#define RCPP_DEBUG( MSG ) Rprintf( "%40s:%4d %s\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG ) ;
37-
#define RCPP_DEBUG_1( fmt, MSG ) Rprintf( "%40s:%4d " fmt "\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG ) ;
38-
#define RCPP_DEBUG_2( fmt, M1, M2 ) Rprintf( "%40s:%4d " fmt "\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2 ) ;
39-
#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) ;
40-
#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) ;
41-
#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) ;
36+
#define RCPP_DEBUG( MSG ) Rprintf( "%40s:%4d %s\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG ) ;
37+
#define RCPP_DEBUG_1( fmt, MSG ) Rprintf( "%40s:%4d " fmt "\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG ) ;
38+
#define RCPP_DEBUG_2( fmt, M1, M2 ) Rprintf( "%40s:%4d " fmt "\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2 ) ;
39+
#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) ;
40+
#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) ;
41+
#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) ;
4242
#else
4343
#define RCPP_DEBUG( MSG )
4444
#define RCPP_DEBUG_1( fmt, MSG )
@@ -52,49 +52,49 @@
5252
#define RCPP_DEBUG_MODULE( MSG ) { \
5353
Rcpp::Module * mod__ = getCurrentScope() ; \
5454
if( mod__ ){ \
55-
Rprintf( "[module (%s) <%p> ] %40s:%4d %s\n" , mod__->name.c_str(), mod__, ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG ) ;\
55+
Rprintf( "[module (%s) <%p> ] %40s:%4d %s\n" , mod__->name.c_str(), mod__, ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG ) ;\
5656
} else { \
57-
Rprintf( "[module () ] %40s:%4d %s\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG ) ; \
57+
Rprintf( "[module () ] %40s:%4d %s\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG ) ; \
5858
} \
5959
}
6060
#define RCPP_DEBUG_MODULE_1( fmt, MSG ) { \
6161
Rcpp::Module * mod__ = getCurrentScope() ; \
6262
if( mod__ ){ \
63-
Rprintf( "[module (%s) <%p> ] %40s:%4d " fmt "\n" , mod__->name.c_str(), mod__, ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG ) ;\
63+
Rprintf( "[module (%s) <%p> ] %40s:%4d " fmt "\n" , mod__->name.c_str(), mod__, ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG ) ;\
6464
} else { \
65-
Rprintf( "[module () ] %40s:%4d " fmt "\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG ) ; \
65+
Rprintf( "[module () ] %40s:%4d " fmt "\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, MSG ) ; \
6666
} \
6767
}
6868
#define RCPP_DEBUG_MODULE_2( fmt, M1, M2 ) { \
6969
Rcpp::Module * mod__ = getCurrentScope() ; \
7070
if( mod__ ){ \
71-
Rprintf( "[module (%s) <%p> ] %40s:%4d " fmt "\n" , mod__->name.c_str(), mod__, ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2 ) ;\
71+
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 ) ;\
7272
} else { \
73-
Rprintf( "[module () ] %40s:%4d " fmt "\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2 ) ; \
73+
Rprintf( "[module () ] %40s:%4d " fmt "\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2 ) ; \
7474
} \
7575
}
7676
#define RCPP_DEBUG_MODULE_3( fmt, M1, M2, M3 ) { \
7777
Rcpp::Module * mod__ = getCurrentScope() ; \
7878
if( mod__ ){ \
79-
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 ) ;\
79+
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 ) ;\
8080
} else { \
81-
Rprintf( "[module () ] %40s:%4d " fmt "\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3 ) ; \
81+
Rprintf( "[module () ] %40s:%4d " fmt "\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3 ) ; \
8282
} \
8383
}
8484
#define RCPP_DEBUG_MODULE_4( fmt, M1, M2, M3, M4 ) { \
8585
Rcpp::Module * mod__ = getCurrentScope() ; \
8686
if( mod__ ) { \
87-
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 ) ;\
87+
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 ) ;\
8888
} else { \
89-
Rprintf( "[module () ] %40s:%4d " fmt "\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3, M4 ) ; \
89+
Rprintf( "[module () ] %40s:%4d " fmt "\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3, M4 ) ; \
9090
} \
9191
}
9292
#define RCPP_DEBUG_MODULE_5( fmt, M1, M2, M3, M4, M5 ) { \
9393
Rcpp::Module * mod__ = getCurrentScope() ; \
9494
if( mod__ ){ \
95-
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 ) ;\
95+
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 ) ;\
9696
} else { \
97-
Rprintf( "[module () ] %40s:%4d " fmt "\n" , ::Rcpp::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3, M4, M5 ) ; \
97+
Rprintf( "[module () ] %40s:%4d " fmt "\n" , ::Rcpp::internal::debug::short_file_name(__FILE__).c_str(), __LINE__, M1, M2, M3, M4, M5 ) ; \
9898
} \
9999
}
100100
#else

inst/include/Rcpp/macros/macros.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <string>
2626

2727
namespace Rcpp {
28+
namespace internal {
2829
namespace debug {
2930

3031
inline std::string short_file_name(const char* file)
@@ -37,6 +38,7 @@ inline std::string short_file_name(const char* file)
3738
}
3839

3940
} // namespace debug
41+
} // namespace internal
4042
} // namespace Rcpp
4143

4244
#define RCPP_DECORATE(__FUN__) __FUN__##__rcpp__wrapper__

0 commit comments

Comments
 (0)