Skip to content

Commit be22d58

Browse files
Ensure format strings pass check in R-devel/Windows (#345)
* format strings * Also fixup debug comments * NEWS bullet --------- Co-authored-by: Davis Vaughan <davis@posit.co>
1 parent 8ab2f67 commit be22d58

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# cpp11 (development version)
22

3+
* Internal changes requested by CRAN to fix invalid format string tokens
4+
(@paleolimbot, #345).
5+
36
# cpp11 0.4.6
47

58
* R >=3.5.0 is now required to use cpp11. This is in line with (and even goes

inst/include/cpp11/protect.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,9 @@ static struct {
279279
void print() {
280280
static SEXP list = get_preserve_list();
281281
for (SEXP cell = list; cell != R_NilValue; cell = CDR(cell)) {
282-
REprintf("%x CAR: %x CDR: %x TAG: %x\n", cell, CAR(cell), CDR(cell), TAG(cell));
282+
REprintf("%p CAR: %p CDR: %p TAG: %p\n", reinterpret_cast<void*>(cell),
283+
reinterpret_cast<void*>(CAR(cell)), reinterpret_cast<void*>(CDR(cell)),
284+
reinterpret_cast<void*>(TAG(cell)));
283285
}
284286
REprintf("---\n");
285287
}

inst/include/cpp11/sexp.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ class sexp {
2020
sexp() = default;
2121

2222
sexp(SEXP data) : data_(data), preserve_token_(preserved.insert(data_)) {
23-
// REprintf("created %x %x : %i\n", data_, preserve_token_, protect_head_size());
23+
// REprintf("created %p %p\n", reinterpret_cast<void*>(data_),
24+
// reinterpret_cast<void*>(preserve_token_));
2425
}
2526

2627
sexp(const sexp& rhs) {
2728
data_ = rhs.data_;
2829
preserve_token_ = preserved.insert(data_);
29-
// REprintf("copied %x new protect %x : %i\n", rhs.data_, preserve_token_,
30-
// protect_head_size());
30+
// REprintf("copied %p new protect %p\n", reinterpret_cast<void*>(rhs.data_),
31+
// reinterpret_cast<void*>(preserve_token_));
3132
}
3233

3334
sexp(sexp&& rhs) {
@@ -37,15 +38,15 @@ class sexp {
3738
rhs.data_ = R_NilValue;
3839
rhs.preserve_token_ = R_NilValue;
3940

40-
// REprintf("moved %x : %i\n", rhs.data_, protect_head_size());
41+
// REprintf("moved %p\n", reinterpret_cast<void*>(rhs.data_));
4142
}
4243

4344
sexp& operator=(const sexp& rhs) {
4445
preserved.release(preserve_token_);
4546

4647
data_ = rhs.data_;
4748
preserve_token_ = preserved.insert(data_);
48-
// REprintf("assigned %x : %i\n", rhs.data_, protect_head_size());
49+
// REprintf("assigned %p\n", reinterpret_cast<void*>(rhs.data_));
4950
return *this;
5051
}
5152

0 commit comments

Comments
 (0)