Do any compilers currently support C++20? - c++

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"

Related

Some troubles with compiler mingw_w64

Yesterday I started making some project and today I check out that my compiler (mingw_w64) is the newest one which I find in Internet (8.1) but I don't have all functions from C++20. So maybe someone know how to figure out this? If it somehow help my IDE is QT creator.
C++ ISO standards and compilers do not progress at the same pace or with the same priorities. Also, C++ standards are available (drafts) before they are complete or officially published: quite often, compilers partially support the draft specs. The good side of this is that there are tables telling you what feature of a given standard is supported by a given version of GCC. You can find such a table for GCC here.
The current latest release of GCC is GCC 11 and C++20 support has been available since GCC 10.
Another compiler is LLVM/Clang, but I don't believe their C++20 support is on the same level as GCC yet, though I excpect it to catch up soon.
Get the latest MinGW-w64 GCC build from: http://winlibs.com/

C++ versions, what they mean, how to update them

Is the c++ version you use tied to the version of compiler you have or IDE?
If it isn't either of those, how do I use c++ 11 on my IDE? How do i update what C++ version i use in my programs?
How do I check what version I'm using?
I know that printing the __cplusplus variable can tell me what version I'm using, but this doesn't answer my other questions, neither does it answer my third question, because: https://stackoverflow.com/a/14131551/10938047
Found this question, with the answer containing an outdated link.
Visual Studio 2012 __cplusplus and C++ 11
The C++ version you can use is obviously tied to the compiler you use. If your compiler doesn't support some newer standard then of course you cannot use it.
As for IDEs; some IDEs are tied to a specific compiler, some can use different ones.
Some compilers support multiple language versions but require you to explicitly enable anything newer than what they enable by default. For example; most older versions of GCC support C++17 just fine, but default to C++11 or C++14 unless you tell them to enable C++17 support via the -std=c++17 command line option.

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++.

Run C++ Code Online?

Is there a website I can go to to run C++ code online? I have seen a few compilers, but is there one that can also receive input from cin? I want one that can basically host a C++ .exe online, and even more preferable is if it is like the VC++ platform.
You may want to give rextester a try. Currently g++ 4.7.2 with boost libraries and ability to supply compiler args.
Edit
Visual C++ is also supported now.
http://ideone.com/ Can compile several languages, and supports stdin
Yes, Ideone can do that. It's possible to specify stdin there.
Edit: Microsoft's online compiler seems to no longer be active :(
Microsoft research have made an online version of Visual C++ here: http://webcompiler.cloudapp.net/.
It (currently?) only compiles the code and does not run it so you won't be able to check cin though :(
Running code is now supported.
Currently the best online tools seem to be
Special Online Compilers
https://cppinsights.io shows, how C++ introduces conversions, etc. and interprets the source code (current clang based)
https://godbolt.org compare C++ compilers, show disassembly, run (many current compilers including Microsoft VCC and embedded compilers)
http://quick-bench.com create and compare benchmarks (current g++ and clang)
https://www.onlinegdb.com, includes gdb debugger (g++ 7.4.0)
Online Compilers that let you set compile flags
https://wandbox.org (current g++ and clang)
http://coliru.stacked-crooked.com (g++ 9.2.0)
https://repl.it/languages/cpp11 (clang 7.0.0)
https://www.tutorialspoint.com/compile_cpp11_online.php = codingground (g++ 7.1.1)
https://tio.run/#cpp-clang (g++ 8.3.1 and clang 7.0.1)
https://rextester.com/l/cpp_online_compiler_gcc (g++ 7.4.0, clang 6.0.0, VS C++ 2015 Update 1)
Online Compilers that do not let you set compile flags
https://www.jdoodle.com (g++ 9.2.0)
https://www.codechef.com/ide (g++ 9.1.0)
https://ideone.com (g++ 8.3.0 and clang 8.0.0)
https://paiza.io (clang 8.0.0)
https://www.codiva.io/c (clang 7.1.0)
https://code.labstack.com/cpp (g++ 8.3.0)
All listed compilers support C++17 code
Perhaps the following site is what you're aiming for: http://codepad.org/
There is Wandbox.org, which offers GCC and Clang to its latest versions (as of Nov 2018). It has stdin.
I wouldn't say it's a VC++ platform though.
TutorialsPoint's C++ Coding Ground lets you save and compile multiple source files at a time, which can be useful at times, and gives you a GNU bash console to play around with. It's not as convenient for sharing code as sites like Ideone, however.
[Note: While it only has links to C++, C++0x, and C++11 environments, you can compile code for C++14 by specifying the compiler option -std=c++1y. I'm not sure if it has any experimental C++17 support, however.]
repl.it can compile, run, and execute C++ and C++11. It's also interactive and you can ask for user input in realtime.

what c++ norme i'm currently using? [duplicate]

This question already has answers here:
How to determine the version of the C++ standard used by the compiler?
(9 answers)
Closed 6 years ago.
Recently I had faced compiling errors in a c++ code I wrote so I've been asked if I was using a C++11 compiler, but honestly I don't know how to check on my compiler version ! so any idea how to figure this out ??
Btw I'm using codeblocks as an IDE which includes the GCC compiler and GDB debugger from MinGW. also if I'm compiling my c++ code under Linux what command should I run to know my compiler version ?
That can be a tricky question. C++11 refers to a version of the
standard, not to a version of the compiler. Different compilers, and
different versions of any given compiler, will typically implement a mix
of versions of the standard, at least for recent versions. More or
less, because any implementation of C++11 will be fairly new, and thus
probably fairly buggy.
Most compilers have options to output the version; many will output it
systematically in verbose mode. For g++, try g++ --version. Recent
versions of g++ do have some support for C++11, but you have to activate
it with -std=c++0x (rather than the usual -std=c++03 or
-std=c++98). As the name (c++0x, rather than c++11) indicates, it
is not truly C++11; it is an implementation of some (most?) of the
major new features, in a preliminary version based on various working
papers, and not the final standard.
(FWIW: I don't think any compiler fully implements all of C++11, but I'd
love to be proven wrong.)
You can find out your compiler version like this:
g++ --version
That doesn't tell you if you are using c++11. To use c++11 features, you would have to call the compiler with thr -std=c++0x flag:
g++ -std=c++0x ....
Bear in mind that gcc doesn't implement 100% of c++11 yet, and how much it implements depends on the version. See here for a table of supported features.
EDIT: strictly speaking, if you are using GCC you cannot be using a fully compliant c++11 compiler due to the missing features. But versions 4.6.1 onwards cover a great deal of the standard.
If you're in linux, checking the version is easy.
> gcc --version
Will tell you the version you have. Note that GCC C++11 support is incomplete still, you can find the details here: http://gcc.gnu.org/projects/cxx0x.html
I've used a few C++11 features myself, namely initializer lists, and the nullptr constant. I'm using GCC 4.6 and it's working fine.
edit: And yes, as #jaunchopanza said, you'll need the -std=c++0x compiler flag to make it work. If you're using Code::Blocks, just right-click on your project, choose Build options..., and check the item that says Have g++ follow the coming C++0x ISO C++ language standard [-std=c++0x]