How can I update my C++ version on VSCode to C++20? - c++

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.

Related

Do any compilers currently support C++20?

I purchased a book recently entitled beginning C++20. I was looking to begin learning c++ though I now realize that I can't find a compiler that can run the code in the book as I get an error since the compiler I'm using (xcode) does not support c++ 20. I'm wondering if there are any compilers that I can run on my mac that support c++20.
gcc version 8 and up supports some of C++20; you can try using that.
It should also be noted that Xcode isn't a compiler, but instead an IDE that should be using clang as the actual compiler. Clang also currently has support for some of the C++ 20 features. To use them the -std=c++20 flag will still be needed.
Here can you find the currently implemented feature support of the GCC compiler of the C++20 specification:
GCC Link
But you need to enable it in your console command or add this to your toolchain: "-std=c++20"

"Have g++ follow the C++14 ISO C++ language standard [-std=c++14] " not seeing in codeblock?

I am new to coding and programming so please answer my question. Before i had "Have g++ follow the C++14 ISO C++ language standard [-std=c++14]" in my codeblock IDE. But last day i did a default reset in complier settings. After the reset "Have g++ follow the C++14 ISO C++ language standard [-std=c++14]" is not visible in the complier flags options. I tried re-installation of codeblock but it didnt work. how to reset codeblock to get the option back. Also what is the difference between ...std c++14 and ..std c++11.
The difference between c++11 and c++14 is minor.
Each one is a standard, which defines what c++ is. C++14 mostly extends C++11 with features, that didnt make it in time to c++11.
Its rather an extension to c++11, then a big jump in version like c++03 to c++11.
Using c++14 in Codeblocks must be done with the Compilerflags.
These must enable --std=c++14 -> The settings is not related to Codeblocks, but to the compiler that codeblocks uses.

xcode 5.1.1 complaining: ISO C++11 does not allow access declarations

I have a project that builds and runs fine on Xcode 4.6.3.
But it does not on Xcode 5.1.1.
This is the unique error I get, hundred times.
"ISO C++11 does not allow access declarations; use using declarations instead".
Basically it wants me to go from:
typedef Something<MType>::Index Index;
Something<MType>::N;
to
typedef Something<MType>::Index Index;
using Something<MType>::N;
Why is it?
If I "solve it" as Xcode says, the final app behaves randomly.
Is it possible to build this project on Xcode 5.1.1 as if it were 4.6.3? (in other words: changing the project settings, but keeping the code intact)
AFAIS, the C++ flags have the same value for both Xcode versions.
C Language Dialect = GNU99 [-std=gnu99]
C++ Language Dialect = GNU++11 [-std=gnu++11]
C++ standard library = libc++ (LLVM C++ standard library with C++11 support)
It looks like a deliberate change to the compiler:
http://llvm.org/viewvc/llvm-project?view=revision&revision=183882
The standards body says: "Access declarations were deprecated in the 1998 standard and have no benefits over using-declarations. They should be removed in C++0x."
And I can't find anyway of reverting to an older (non-standard compliant) C++11 behaviour. I was half expecting this to work:
clang -std=c++0x
But, it doesn't. You get the same error.
Including using looks like the right fix. I've just done some testing here and it does what it says on the tin.
Probably not what you want to hear, but I think you should look into why the code behaves randomly when you use the using directive.

Xcode 5.1 compile against C++98, avoid C++11 features

I'm currently working on a project that primarily uses C++98 as a coding standard for backwards compatibility. I'm working on OSX10.9 mavericks and have compiled all dependencies against libc++.
I would like to configure Xcode in such a way that it gives me a warning or doesn't compile when I use C++11 language features.
Compiling with the -std=c++98 flag didn't show any errors/notifications concerning the use of C++11 features.
I didn't enable the "Using C++11 extensions in earlier versions of C++"-warning. Now XCode will show me a compiler warning if I use C++11 features.
To check if I use library features from the new standard I still have to link libstdc++.

Detecting C++0x mode on Intel C++?

Does Intel C++ predefine some macro when compiling with Qstd=c++0x? Something like __GXX_EXPERIMENTAL_CXX0X__ in GCC? __cplusplus is still 199711.
Any way to detect C++0x compilation?
The Intel documentation indicates that it does define __GXX_EXPERIMENTAL_CXX0X__ on Linux, but does not define any macro on Windows.
On the current (2013-08-06) Intel Composer XE 2013 Update 5 for Windows, the list of preprocessor definitions includes
#define __INTEL_CXX11_MODE__ 1
if and only if C++0x mode is enabled.