Visual C++ standards compliance [closed]

ぐ巨炮叔叔 提交于 2019-12-09 14:29:02

问题


I was wondering if, and to what degree, does Microsoft's Visual C++ compiler conform to the current C (C90/C99) and C++ (ISO/IEC 14882:2003) standards. Unfortunately I'm only able to find partial information on the subject, I may be looking at all the wrong places.

Any pointers to related resources are much appreciated. Thanks in advance.

Edit: Since is looks like this is a most touchy subject, I'd be content with a yes/no answer on whether MSVC wholly conforms to C90...I've come to the understanding that this is not the case for C99 (naturally), and I still have no clue about C++..

Edit2: Thanks to everyone for their answers. I've accepted Mr. Rushakov's answer but upvoted all relevant answers, which were all helpful.


回答1:


Perhaps MSDN's Nonstandard Behavior page for Visual C++ will enlighten you? Make sure you look at the version you're most interested in (the box on the right-hand side).

Since MSDN's links change all the time (and who knows why), here's the main content from the page on VS2008, so when the link breaks and someone comes across this answer, they can Google and find the correct page:

Nonstandard Behavior

The following topics are some of the known places where the Visual C++ implementation of C++ does not agree with the C++ standard. The section numbers refer to section numbers in the C++ standard.

  • Compiler Limits
  • 10.3 (Paragraph 5) Covariant Return Types
  • 14 export Keyword on a Template
  • 14.6.2 Dependent Names
  • 15.4 Function Exception Specifiers
  • 16.3.2 The # Operator
  • 21.1.1 Character Traits Requirements
  • Storage Location of Objects



回答2:


My pet peeves, which most programmers find unimportant but which I personally find to hurt readability a lot, is that VC++ is unable to compile the following C++ code:

bool result = true and not false;

… because VC++ doesn’t recognize and, or and not (along with the rest of ISO 646) as valid tokens.

Clarification: The standard mentions the treatment of the above tokens in §2.12, marks them as reserved in §2.11 and defines an equivalence mapping for them in §2.5 to the more conventional operator representations (e.g. and corresponds to &&). It isn’t clear why they get a special status next to the other keywords. Even more confusingly, appendix C2.2 suddenly calls them “keywords”. Still, the standard is absolutely clear about their treatment and semantics. VC simply doesn’t implement these paragraphs (unless you specify the /Za flag during compilation).




回答3:


Here's a nice summary in the MSDN blog titled 'C++11 Features in Visual C++ 11' which was updated March 2nd, 2012.




回答4:


Visual C++ 2k3, 2k5, and 2k8, conform to C89, and C++98.

Some additional features are cherry-picked from C99, and there are a few enhancements on top of C++98.




回答5:


Standards compliance for C and C++ has been rather poor for VS. Things began changing with 2005 and is getting better. VS2010 is what I am really looking at with quite a lot of features from C++0x. Most of the time though, I end up Googling with the following keywords:

  • msdn ANSI C conformance
  • msdn ISO C++ conformance

etc. when I really really need to figure out why something doesn't work as defined.




回答6:


I don't use VS 2008 yet, so I can only speak for VS 2005.

It doesn't support C99. Support for C89/90 has always been good in VC and I'm not aware of any non-compliance issues with it.

C++98 support has a number of issues, some of them are documented by MS as known issues and some are plain bugs. I made a blog entry to use as a "notebook" for various VS 2005 C++ bugs I encounter in practice. If you wish, you can take a look here, although this list is probably far from being complete




回答7:


__try is marked as an extension



来源:https://stackoverflow.com/questions/1599960/visual-c-standards-compliance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!