当默认标准为 201402L (c++14) 时,g++ 是否与 g++ -std=c++14 不同?

Is g++ different than g++ -std=c++14 when the default standard is 201402L (c++14)?

我试图利用预编译头文件来加快编译速度 link:https://codeforces.com/blog/entry/53909

我观察到头文件的预编译和 .cpp 程序的后续编译必须使用相同的 g++ 标志来完成加速工作,这是有道理的。但是,将 c++ 标准显式设置为默认标准不起作用。因此,使用 g++ stdc++.h 和随后的 g++ -std=c++14 program.cpp 进行预编译,g++ -std=c++14g++ program.cpp 都没有工作。

这对我来说没有意义,因为我知道我的编译器 x86_64-w64-mingw32-g++.exe(gcc 版本 10.2.0)默认符合 201402L (c++14) 标准,我认为使用 g++ -dM -E -x c++ /dev/null | fgrep __cplusplus,并得到以下响应:

#define __cplusplus 201402L

所以,我的问题是,当 g++ 默认遵守 201402L 时,g++ 和 g++ -std=c++14 有什么区别?另外,是否足以让我专门选择其中之一?

GCC 默认不使用 -std=c++14 编译。 GCC man pages(对于版本 9.3.0)中的 -std 标志的描述说

-std= Determine the language standard. This option is currently only supported when compiling C or C++.

The compiler can accept several base standards, such as c90 or c++98, and GNU dialects of those standards, such as gnu90 or gnu++98. When a base standard is specified, the compiler accepts all programs following that standard plus those using GNU extensions that do not contradict it.
. . .
A value for this option must be provided; possible values are
. . .
c++14
c++1y
    The 2014 ISO C++ standard plus amendments. The name c++1y is deprecated.

gnu++14
gnu++1y
    GNU dialect of -std=c++14. This is the default for C++ code. The name gnu++1y is deprecated.
. . .

强调我的。当前默认值为 -std=gnu++14,它针对 C++14 标准,同时还启用 GNU extensions to the C++ language. The distinction between the -std=c++XX flags and the -std=gnu++XX flags is explained further in What are the differences between -std=c++11 and -std=gnu++11?.