2

I am attempting to add the numbers header to my program for pi and euler's number, but my C++ version is C++14, and while I've added "-std=c++2a" to tasks.json and changed the C++ standard to C++20 on the "C/C++" extension, the __cplusplus macro still outputs the indicator for C++14. What else should I try in order to enable C++20? Also GCC ver 9.2.0 is being used.

cigien
  • 57,834
  • 11
  • 73
  • 112
Paradox
  • 33
  • 4
  • Assuming you're on Windows and have MinGW and thus use GCC, which version of GCC do you have? – Some programmer dude Nov 26 '21 at 06:32
  • Also, how do you check `__cplusplus`? – Some programmer dude Nov 26 '21 at 06:32
  • GCC ver 9.2.0. You can cout __cplusplus. – Paradox Nov 26 '21 at 06:35
  • 1
    C++20 support in GCC is still considered "experimental" (according to [the GCC C++ standard status page](https://gcc.gnu.org/projects/cxx-status.html)). It might be that version 9.2.0 is not updating `__cplusplus` correctly? Have you considered upgrading GCC (it's up to 11.2 now)? – Some programmer dude Nov 26 '21 at 06:40
  • Also, perhaps the specific C++20 features you want to use are available anyway, even if `__cplusplus` indicates it's not? Exactly what features are you looking for to use? Have you checked the C++ standard compliance page I linked before, to see when and where that feature was added to GCC (if it has been added)? – Some programmer dude Nov 26 '21 at 06:43
  • I tried to implement #include but that resulted in an error, and I'm only looking to use the numbers header for now. The numbers header doesn't appear to be on the gcc page, but it does seem to be supported judging by the answers in this post: https://stackoverflow.com/questions/69442953/how-to-include-numbers-header-file-and-use-stdnumbers. I tried upgrading gcc using this post: https://stackoverflow.com/questions/9865319/how-to-update-gcc-in-mingw-on-windows, but it still resulted in gcc 9.2. – Paradox Nov 26 '21 at 06:55
  • 1
    According to [GCC's libstdc++ manual](https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2020), ``, aka Mathematical constants, is only supported after gcc 10.1 – Ranoiaetep Nov 26 '21 at 12:38

0 Answers0