# CRAN NOTE for package using Stan (suggest C++17)

**URL:** <https://discourse.mc-stan.org/t/cran-note-for-package-using-stan-suggest-c-17/30247>\
**Category:** Developers\
**Created:** [February 2, 2023, 6:00pm UTC](https://discourse.mc-stan.org/t/cran-note-for-package-using-stan-suggest-c-17/30247 "2023-02-02T18:00:06Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![jeffreypullin](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jeffreypullin/32/8515_2.png) [@jeffreypullin](https://discourse.mc-stan.org/u/jeffreypullin)\
**Post date:** [March 7, 2023, 10:29am UTC](https://discourse.mc-stan.org/t/cran-note-for-package-using-stan-suggest-c-17/30247/41 "2023-03-07T10:29:53Z")

</div>

Hi all,

I am preparing to submit a new version of my [rater](https://github.com/jeffreypullin/rater) package to CRAN.

I’ve run into the new C++14 note and have tried to fix it using the approaches described in this thread (i.e. [here](https://github.com/jeffreypullin/rater/commit/f8d4b0638f669ec114db9797b797d6fa848cc2a0))

However, I’m still getting the note in my [GHA checks](https://github.com/jeffreypullin/rater/actions/runs/4352777527/jobs/7605976349).

I’m out of ideas as to why the check still thinks I am specifying C++14 - any ideas or assistance greatly appreciated!

Jeffrey

@andrjohns @jonah

---

<div class="post-metadata">

**Author:** ![wds15](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/wds15/32/908_2.png) [@wds15](https://discourse.mc-stan.org/u/wds15)\
**Post date:** [March 7, 2023, 3:27pm UTC](https://discourse.mc-stan.org/t/cran-note-for-package-using-stan-suggest-c-17/30247/42 "2023-03-07T15:27:03Z")

</div>

You also need in src/Makevars this:

```plaintext
PKG_CPPFLAGS += -D_HAS_AUTO_PTR_ETC=0

```

also make sure to have C++17 in the SystemRequirements.

---

<div class="post-metadata">

**Author:** ![jonah](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jonah/32/200_2.png) [@jonah](https://discourse.mc-stan.org/u/jonah)\
**Post date:** [March 7, 2023, 6:12pm UTC](https://discourse.mc-stan.org/t/cran-note-for-package-using-stan-suggest-c-17/30247/43 "2023-03-07T18:12:54Z")

</div>

@andrjohns now that Ben reviewed and merged your PRs is there anything else you wanted to get in to the rstantools update or should I go ahead and prepare the CRAN submission?

---

<div class="post-metadata">

**Author:** ![jonah](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jonah/32/200_2.png) [@jonah](https://discourse.mc-stan.org/u/jonah)\
**Post date:** [March 7, 2023, 7:19pm UTC](https://discourse.mc-stan.org/t/cran-note-for-package-using-stan-suggest-c-17/30247/44 "2023-03-07T19:19:34Z")

</div>

Actually we’re getting some GHA failures:

> <https://github.com/stan-dev/rstantools/actions/runs/4346675124/jobs/7593029259>

so we’ll have to sort that out before submitting. While we’re dealing with that I’ll run all the other checks that CRAN wants (e.g., checking on winbuilder) and get everything ready to submit as soon as we’re set.

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [March 9, 2023, 4:44am UTC](https://discourse.mc-stan.org/t/cran-note-for-package-using-stan-suggest-c-17/30247/45 "2023-03-09T04:44:44Z")

</div>

That error is safe to ignore for now, it’s occurring because `stanc3` is emitting `size` without the `math::` namespace qualifier - which is only an issue for the rstan 2.26 and StanHeaders 2.26 combination. I’ll open a PR to backport the stanc3 fixes to `rstan` 2.26, so user’s development workflows shouldn’t break

That’s also all the changes from me, thanks!

EDIT: [rstan PR opened](https://github.com/stan-dev/rstan/pull/1044)

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [March 9, 2023, 5:52am UTC](https://discourse.mc-stan.org/t/cran-note-for-package-using-stan-suggest-c-17/30247/46 "2023-03-09T05:52:52Z")

</div>

Actually, there’s one more minor patch needed for the `stanfunctions` support that I’ve just identified while testing the patch mentioned above, will open in just a tick

EDIT: @jonah rstantools PR [opened here](https://github.com/stan-dev/rstantools/pull/103). The GHA will still fail for 2.26 until the above rstan PR is merged and new binaries released

EDIT 2: New binaries released and GHA checks passing now

---

<div class="post-metadata">

**Author:** ![jonah](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jonah/32/200_2.png) [@jonah](https://discourse.mc-stan.org/u/jonah)\
**Post date:** [March 9, 2023, 5:24pm UTC](https://discourse.mc-stan.org/t/cran-note-for-package-using-stan-suggest-c-17/30247/47 "2023-03-09T17:24:08Z")

</div>

Thanks @andrjohns! I’m going to try to submit to CRAN later today.

---

<div class="post-metadata">

**Author:** ![jonah](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jonah/32/200_2.png) [@jonah](https://discourse.mc-stan.org/u/jonah)\
**Post date:** [March 9, 2023, 7:59pm UTC](https://discourse.mc-stan.org/t/cran-note-for-package-using-stan-suggest-c-17/30247/48 "2023-03-09T19:59:37Z")

</div>

I just submitted the rstantools update to CRAN. I’ll give another update here when it has been accepted. Thanks everyone for your patience and help getting this sorted out!

---

<div class="post-metadata">

**Author:** ![jeffreypullin](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jeffreypullin/32/8515_2.png) [@jeffreypullin](https://discourse.mc-stan.org/u/jeffreypullin)\
**Post date:** [March 9, 2023, 10:46pm UTC](https://discourse.mc-stan.org/t/cran-note-for-package-using-stan-suggest-c-17/30247/49 "2023-03-09T22:46:16Z")

</div>

Brilliant! Thanks so much for your work on this @jonah and @andrjohns!

---

<div class="post-metadata">

**Author:** ![jonah](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jonah/32/200_2.png) [@jonah](https://discourse.mc-stan.org/u/jonah)\
**Post date:** [March 9, 2023, 11:02pm UTC](https://discourse.mc-stan.org/t/cran-note-for-package-using-stan-suggest-c-17/30247/50 "2023-03-09T23:02:12Z")

</div>

rstantools v2.3.0 is now on CRAN (probably the shortest submission to acceptance wait I’ve ever had):

> **[rstantools: Tools for Developing R Packages Interfacing with 'Stan'](https://cran.r-project.org/web/packages/rstantools/index.html)**
>
> Provides various tools for developers of R packages interfacing with 'Stan' \<https://mc-stan.org\>, including functions to set up the required package structure, S3 generics and default methods to unify function naming across 'Stan'-based R...

It will probably be a few days until binaries are available but installing from source should work already.

---

<div class="post-metadata">

**Author:** ![jonah](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jonah/32/200_2.png) [@jonah](https://discourse.mc-stan.org/u/jonah)\
**Post date:** [March 9, 2023, 11:36pm UTC](https://discourse.mc-stan.org/t/cran-note-for-package-using-stan-suggest-c-17/30247/51 "2023-03-09T23:36:05Z")

</div>

> [@jeffreypullin](#):
>
> Brilliant! Thanks so much for your work on this @jonah and @andrjohns!

Mostly @andrjohns!

---

<div class="post-metadata">

**Author:** ![jeffreypullin](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jeffreypullin/32/8515_2.png) [@jeffreypullin](https://discourse.mc-stan.org/u/jeffreypullin)\
**Post date:** [March 12, 2023, 2:36am UTC](https://discourse.mc-stan.org/t/cran-note-for-package-using-stan-suggest-c-17/30247/52 "2023-03-12T02:36:10Z")

</div>

Very happy to report that the new version of my package rater was swiftly accepted onto CRAN.

---

<div class="post-metadata">

**Author:** ![Charles\_Driver](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/charles_driver/32/6524_2.png) [@Charles\_Driver](https://discourse.mc-stan.org/u/Charles_Driver)\
**Post date:** [March 14, 2023, 9:56am UTC](https://discourse.mc-stan.org/t/cran-note-for-package-using-stan-suggest-c-17/30247/53 "2023-03-14T09:56:27Z")

</div>

c++17 is still not expected to work with rstan 2.26, right? when I test this compilation just seems to get stuck…

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [March 14, 2023, 10:20am UTC](https://discourse.mc-stan.org/t/cran-note-for-package-using-stan-suggest-c-17/30247/54 "2023-03-14T10:20:48Z")

</div>

Which 2.26.x version are you on? The latest is 2.26.17, and has been fine with all C++17 so far

---

<div class="post-metadata">

**Author:** ![Charles\_Driver](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/charles_driver/32/6524_2.png) [@Charles\_Driver](https://discourse.mc-stan.org/u/Charles_Driver)\
**Post date:** [March 14, 2023, 10:26am UTC](https://discourse.mc-stan.org/t/cran-note-for-package-using-stan-suggest-c-17/30247/55 "2023-03-14T10:26:33Z")

</div>

2.26.17. I’ll check on m windows box when I can to see if it’s a package issue or some machine specific issue on my ubuntu box…

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [March 14, 2023, 11:42am UTC](https://discourse.mc-stan.org/t/cran-note-for-package-using-stan-suggest-c-17/30247/56 "2023-03-14T11:42:48Z")

</div>

I can build and install `ctsem`’s `master` branch with 2.26.17 and specifying `CXX_STD = CXX17` in the `Makevars` on MacOS

---

<div class="post-metadata">

**Author:** ![Charles\_Driver](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/charles_driver/32/6524_2.png) [@Charles\_Driver](https://discourse.mc-stan.org/u/Charles_Driver)\
**Post date:** [March 14, 2023, 11:47am UTC](https://discourse.mc-stan.org/t/cran-note-for-package-using-stan-suggest-c-17/30247/57 "2023-03-14T11:47:43Z")

</div>

thanks for checking, yes it’s working on windows too, on ubuntu it’s just stuck forever at

```plaintext
/home/dricha/R/x86_64-pc-linux-gnu-library/4.2/BH/include/boost/get_pointer.hpp: At global scope:
/home/dricha/R/x86_64-pc-linux-gnu-library/4.2/BH/include/boost/get_pointer.hpp:48:40: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
   48 | template<class T> T * get_pointer(std::auto_ptr<T> const& p)
      | ^ ~~~~~~~
In file included from /usr/include/c++/9/bits/locale_conv.h:41,
                 from /usr/include/c++/9/locale:43,
                 from /usr/include/c++/9/iomanip:43,
                 from /home/dricha/R/x86_64-pc-linux-gnu-library/4.2/Rcpp/include/RcppCommon.h:53,
                 from /home/dricha/R/x86_64-pc-linux-gnu-library/4.2/Rcpp/include/Rcpp.h:27,
                 from stan_files/ctsmgen.cc:1:
/usr/include/c++/9/bits/unique_ptr.h:53:28: note: declared here
   53 | template<typename> class auto_ptr;
      |        

```

not really sure how to diagnose this one…

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [March 14, 2023, 11:49am UTC](https://discourse.mc-stan.org/t/cran-note-for-package-using-stan-suggest-c-17/30247/58 "2023-03-14T11:49:24Z")

</div>

You’re missing a Makevars flag: ` -D_HAS_AUTO_PTR_ETC=0`

Things like this are why I’d recommend using `rstantools`if you can

---

<div class="post-metadata">

**Author:** ![Charles\_Driver](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/charles_driver/32/6524_2.png) [@Charles\_Driver](https://discourse.mc-stan.org/u/Charles_Driver)\
**Post date:** [March 14, 2023, 11:50am UTC](https://discourse.mc-stan.org/t/cran-note-for-package-using-stan-suggest-c-17/30247/59 "2023-03-14T11:50:51Z")

</div>

I’ve added that in already, doesn’t help, but I am going to see how it goes with rstantools again – I think CRAN has stopped checking on win32 completely which should make it viable without all my workarounds now…

---

<div class="post-metadata">

**Author:** ![Charles\_Driver](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/charles_driver/32/6524_2.png) [@Charles\_Driver](https://discourse.mc-stan.org/u/Charles_Driver)\
**Post date:** [March 15, 2023, 3:18pm UTC](https://discourse.mc-stan.org/t/cran-note-for-package-using-stan-suggest-c-17/30247/60 "2023-03-15T15:18:59Z")

</div>

I think my ubuntu test box was hitting some kind of compiler time out yesterday. confirming now that building ctsem with cpp17 works across platforms with both rstan 2.21 and 2.26. Thanks.

[Previous page](https://discourse.mc-stan.org/t/cran-note-for-package-using-stan-suggest-c-17/30247.md?page=2)
