音が流れない場合、再生を一時停止してもう一度再生してみて下さい。
ツール 
画像
vlogize
0回再生
Understanding g+ + C+ + Version Output: How to Compile with C+ + 20

Learn how to set the C+ + version in g+ + and resolve common version recognition issues.
---
This video is based on the question stackoverflow.com/q/66351305/ asked by the user 'Inyoung Kim 김인영' ( stackoverflow.com/u/8471995/ ) and on the answer stackoverflow.com/a/66351412/ provided by the user 'Thomas Sablik' ( stackoverflow.com/u/4645334/ ) at 'Stack Overflow' website. Thanks to these great users and Stackexchange community for their contributions.

Visit these links for original content and any more details, such as alternate solutions, latest updates/developments on topic, comments, revision history etc. For example, the original title of the Question was: g+ + 10.2 shows cpp version 14

Also, Content (except music) licensed under CC BY-SA meta.stackexchange.com/help/licensing
The original Question post is licensed under the 'CC BY-SA 4.0' ( creativecommons.org/licenses/by-sa/4.0/ ) license, and the original Answer post is licensed under the 'CC BY-SA 4.0' ( creativecommons.org/licenses/by-sa/4.0/ ) license.

If anything seems off to you, please feel free to write me at vlogize [AT] gmail [DOT] com.
---
Understanding g+ + C+ + Version Output: How to Compile with C+ + 20

As a beginner in C+ + , it can be quite perplexing when you compile a program and it appears to be using an older version of the language than you intended. This is especially true when you've recently installed a newer compiler, such as g+ + 10.2, yet your code continues to report that it’s running in C+ + 14. In this post, we’ll explore why this could be happening and how to properly set the C+ + version when compiling your programs.

The Problem

You have a piece of code designed to check the C+ + version in use. The code looks like this:

[[See Video to Reveal this Text or Code Snippet]]

Upon running this code, you receive the output: C+ + 14, even after downloading and installing the latest version of mingw64 10.2. The command g+ + --version shows the correct version, so it's clear that you have the required tools installed. But why does your code still indicate that it's using C+ + 14?

The Solution

To resolve this issue, you'll need to explicitly specify the C+ + standard when you compile your code. This can be achieved using a command-line argument during the compilation process.

Step 1: Specify the C+ + Standard

When using g+ + , you can set the C+ + standard by including the -std flag followed by the desired version. Here are the options you can use:

-std=c+ + 11 for C+ + 11

-std=c+ + 14 for C+ + 14

-std=c+ + 17 for C+ + 17

-std=c+ + 20 for C+ + 20

Step 2: Compiling with the Correct Flag

To compile your program with C+ + 20 (or any other version), run the following command in your terminal:

[[See Video to Reveal this Text or Code Snippet]]

Make sure to replace your_program.cpp with the actual name of your source file.

Example

Using a practical example, if your source file is named version_check.cpp, your command will look like this:

[[See Video to Reveal this Text or Code Snippet]]

Step 3: Run Your Application

After successful compilation, run your application:

[[See Video to Reveal this Text or Code Snippet]]

If everything goes well and your installation supports C+ + 20, you should see the expected output for C+ + 20.

Conclusion

By using the -std flag during compilation, you can control which version of C+ + your code adheres to. This not only helps avoid confusion but also enables you to utilize features from newer standards as they become available. Whether you're using C+ + 11, C+ + 14, C+ + 17, or the latest C+ + 20, always remember to specify the version explicitly to ensure your program compiles as expected.

Now you're all set to investigate and enjoy the rich features that the newer versions of C+ + bring!

コメント