微软C/C++:"strict conformance"w.r.t的定义是什么。执行?

Microsoft C/C++: what is the definition of "strict conformance" w.r.t. implementation?

上下文:

/Za, /Ze (Disable Language Extensions):

... the C compiler conforms strictly to the C89/C90 standard

/permissive- (Standards conformance):

... and sets the /Zc compiler options for strict conformance

C++ Conformance improvements, behavior changes, and bug fixes in Visual Studio 2019:

... /permissive may be specified to turn off strict conformance mode in the compiler.

The second option is meant to disable the strict conformance mode ...

clock:

Note that this is not strictly conformant with ISO C99 ...

Walkthrough: Compile a C program on the command line:

MSVC is compatible with the ANSI C89 and ISO C99 standards, but not strictly conforming.

问:“严格符合”的定义是什么?是微软发明的吗?

注意:C (n2596.pdf) 和 C++ (n4849.pdf) 标准都没有使用术语“严格符合”/“严格符合”应用于实现。实现要么符合,要么不符合。 W/o 渐变。

更新。我的猜测:在“严格一致性”(w.r.t。到实施)下,微软的意思是“符合实施 w/o 支持任何扩展”。

C11 standard 在第 4 节第 5-7 段中定义了一个严格符合的程序和实现如下:

5 A strictly conforming program shall use only those features of the language and library specified in this International Standard. It shall not produce output dependent on any unspecified, undefined, or implementation-defined behavior, and shall not exceed any minimum implementation limit.

6 The two forms of conforming implementation are hosted and freestanding. A conforming hosted implementation shall accept any strictly conforming program. A conforming freestanding implementation shall accept any strictly conforming program in which the ∗ use of the features specified in the library clause (clause 7) is confined to the contents of the standard headers <float.h>, <iso646.h>, <limits.h>, <stdalign.h>, <stdarg.h>, <stdbool.h>, <stddef.h>, <stdint.h>, and <stdnoreturn.h>. A conforming implementation may have extensions (including additional library functions), provided they do not alter the behavior of any strictly conforming program.

7 A conforming program is one that is acceptable to a conforming implementation.

虽然术语严格符合实施严格符合没有出现在这里,但它们可以理解为实施(在给定模式)将只接受严格符合的程序(或更准确地说,不支持标准中未指定的功能的实现)。

您感到困惑的一个关键部分是 /Za 和 /Ze 已被弃用并且很久没有更新了。它是为 ANSI 98 引入的,此后一直没有改变。不要使用这些开关,并忽略文档中对它们的任何引用。

现代 Visual C++“一致性”开关是 /permissive- 和各种 /Zc 开关,结合 /std.

当前“最符合”的选项是:

  • C++20 是:/std:c++20
  • C++17 是:/std:c++17 /permissive- /Zc:preprocessor.
  • C++14 是:/std:c++14 /permissive- /Zc:preprocessor.
  • C11 是:/std:c11
  • C17 是:/std:c17

https://devblogs.microsoft.com/cppblog/msvc-cpp20-and-the-std-cpp20-switch/

Visual C++ 的部分一致性问题与预处理器有关

https://devblogs.microsoft.com/cppblog/announcing-full-support-for-a-c-c-conformant-preprocessor-in-msvc/

https://devblogs.microsoft.com/cppblog/c11-and-c17-standard-support-arriving-in-msvc/

有关逐个功能的细分,请参阅 Microsoft Docs