Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Microsoft Visual C++
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Compatibility == === ABI === The Visual C++ compiler [[Application binary interface|ABI]] has historically changed between major compiler releases.<ref>Microsoft MSDN: [http://msdn.microsoft.com/en-us/library/bb531344.aspx Breaking Changes in Visual C++]</ref> This is especially the case for STL containers, where container sizes have varied a lot between compiler releases.<ref>Microsoft MSDN: [http://msdn.microsoft.com/en-us/library/vstudio/hh438470.aspx Containers (Modern C++)]</ref> Microsoft therefore recommends against using C++ interfaces at module boundaries when one wants to enable client code compiled using a different compiler version. Instead of C++, Microsoft recommends using [[C (programming language)|C]]<ref>Microsoft MSDN: [http://msdn.microsoft.com/en-us/library/vstudio/hh438475.aspx Portability At ABI Boundaries (Modern C++)]</ref> or [[Component Object Model|COM]]<ref>Microsoft forum: [http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/86eda6a7-4d90-4e19-a9d4-6cbe22b661f4 Binary compatibility across Visual C++ versions] {{Webarchive|url=https://archive.today/20130216110824/http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/86eda6a7-4d90-4e19-a9d4-6cbe22b661f4 |date=2013-02-16 }}</ref> interfaces, which are designed to have a stable ABI between compiler releases. All 14.x MSVC releases have a stable ABI,<ref>docs.microsoft.com: [https://docs.microsoft.com/en-us/cpp/porting/binary-compat-2015-2017? C++ binary compatibility between Visual Studio 2015, 2017, and 2019]</ref> and binaries built with these versions can be mixed in a forwards-compatible manner, noting the following restrictions: * The toolset version used must be equal to or higher than the highest toolset version used to build any linked binaries. * The MSVC Redistributable version must be equal to or higher than the toolset version used by any application component. * Static libraries or object files compiled with /GL (Whole program optimisation) are not binary compatible between versions and must use the exact same toolset. === C runtime libraries === Visual C++ ships with different versions of C runtime libraries.<ref name="MSVCRuntime">[http://msdn.microsoft.com/en-us/library/abx4dbyh.aspx C Run-Time Libraries]</ref> This means users can compile their code with any of the available libraries. However, this can cause some problems when using different components ([[Dynamic-link library|DLLs]], [[EXE]]s) in the same program. A typical example is a program using different [[Library (computing)|libraries]]. The user should use the same [[C standard library|C Run-Time]] for all the program's components unless the implications are understood. Microsoft recommends using the [[Thread (computer science)|multithreaded]], dynamic link library (/MD or /MDd compiler option) to avoid possible problems.<ref name="MSVCRuntime" /> ==== POSIX ==== Although Microsoft's CRT implements a large subset of [[POSIX]] interfaces, the Visual C++ compiler will emit a warning on ''every'' use of such functions by default. The rationale is that C and C++ standards require an underscore prefix before implementation-defined interfaces, so the use of these functions are non-standard.<ref>{{cite web |title=Compatibility |url=https://docs.microsoft.com/en-us/cpp/c-runtime-library/compatibility |website=Microsoft: CRT library features |date=26 October 2022 |language=en-us}}</ref> However, systems that are actually POSIX-compliant would not accept these underscored names, and it is more portable to just turn off the warning instead. === C === Although the product originated as an IDE for the [[C (programming language)|C]] programming language, for many years the compiler's support for that language conformed only to the original edition of the [[ANSI C|C standard]], dating from 1989, but not the [[C99]] revision of the standard. There had been no plans to support C99 even in 2011, more than a decade after its publication.<ref>{{cite web|url=https://connect.microsoft.com/VisualStudio/feedback/details/653336/c99-support|title=C99 support|work=Microsoft Connect|archive-url=https://web.archive.org/web/20160304185822/http://connect.microsoft.com/VisualStudio/feedback/details/653336/c99-support|archive-date=2016-03-04|url-status=dead|access-date=2015-09-21}}</ref> Visual C++ 2013 finally added support for various C99 features in its C mode (including designated initializers, compound literals, and the <code>_Bool</code> type),<ref>{{cite web|title=What's New for Visual C++ in Visual Studio 2013|url=https://msdn.microsoft.com/en-us/library/hh409293(v=vs.120).aspx|work=Microsoft Developer Network| date=28 April 2015 |publisher=Microsoft}}</ref> though it was still not complete.<ref>{{cite web|url=http://blogs.msdn.com/b/vcblog/archive/2013/07/19/c99-library-support-in-visual-studio-2013.aspx|title=C99 library support in Visual Studio 2013|author=Pat Brenner|date=July 19, 2013|publisher=Microsoft|work=Visual C++ Team Blog}}</ref> Visual C++ 2015 further improved the C99 support, with full support of the C99 Standard Library, except for features that require C99 language features not yet supported by the compiler.<ref>{{cite web|url=https://msdn.microsoft.com/en-us/library/hh409293(v=vs.140).aspx|title=What's New for Visual C++ in Visual Studio 2015|work=Microsoft Developer Network|date=3 January 2018 |publisher=Microsoft}}</ref> Most of the changes from the [[C11 (C standard revision)|C11]] revision of the standard were still not supported by Visual C++ 2017.<ref>{{cite web|url=https://docs.microsoft.com/en-us/cpp/build/walkthrough-compile-a-c-program-on-the-command-line|title=Walkthrough: Compile a C program on the command line|work=Visual C++ Documentation|date=10 May 2022 |publisher=Microsoft}}</ref> For example, generic selections via the <code>_Generic</code> keyword are not supported by the compiler and result in a syntax error.<ref>{{cite web|url=https://developercommunity.visualstudio.com/content/problem/250665/msvc-2017-does-not-support-generic-type-generic-ma.html|title=MSVC 2017 does not support _Generic (type generic macros) in C}}</ref> The preprocessor was overhauled in 2018, with C11 in sight:<ref>{{cite web |last=Luvsanbat |first=Bat-Ulzii |date=July 6, 2018 |title=MSVC Preprocessor Progress towards Conformance |url=https://devblogs.microsoft.com/cppblog/msvc-preprocessor-progress-towards-conformance/ |publisher=Microsoft |work=Visual Studio Team Blog |url-status=live |archive-url=https://web.archive.org/web/20240303170213/https://devblogs.microsoft.com/cppblog/msvc-preprocessor-progress-towards-conformance/ |archive-date=3 Mar 2024}}</ref> {{blockquote|Full C11 conformance is on our roadmap, and updating the preprocessor is just the first step in that process. The C11 <code>_Generic</code> feature is not actually part of the preprocessor, so it has not yet been implemented. When implemented I expect the feature to work independently of if the traditional or updated preprocessor logic is used.}} <code>_Generic</code> support has been committed to MSVC as of February 2020.<ref>{{cite web|url=https://www.reddit.com/r/cpp/comments/hjn4uv/c20_features_and_fixes_in_vs_2019_161_through_166/fwsil0q/?context=3 |title=C++20 Features and Fixes |date=July 3, 2020 |website=[[reddit]]}}</ref> In September 2020, Microsoft announced C11 and C17 standards support in MSVC would arrive in version 16.8.<ref>{{cite web|url=https://devblogs.microsoft.com/cppblog/c11-and-c17-standard-support-arriving-in-msvc/|title=C11 and C17 Standard Support Arriving in MSVC|date=September 14, 2020}}</ref> This did not include optional features but Microsoft indicated that they were planning to add support for atomics and threads at a later date. In version 17.5, partial (since [[Lock (computer science)|atomic locks]] are missing) and experimental (meaning hidden behind the compiler flag <code>/experimental:c11atomics</code>) support for atomics was added<ref>{{cite web|url=https://devblogs.microsoft.com/cppblog/c11-atomics-in-visual-studio-2022-version-17-5-preview-2/|title=C11 Atomics in Visual Studio 2022 version 17.5 Preview 2|date=2022-12-13}}</ref> and in version 17.8, support for threads was added, this time not behind a compiler flag.<ref>{{cite web|url=https://devblogs.microsoft.com/cppblog/c11-threads-in-visual-studio-2022-version-17-8-preview-2/|title=C11 Threads in Visual Studio 2022 version 17.8 Preview 2|date=2023-09-26}}</ref><ref>{{Cite web |last=Murphy |first=Adrian |date=2023-11-14 |title=Visual Studio 17.8 now available! |url=https://devblogs.microsoft.com/visualstudio/visual-studio-17-8-now-available/ |access-date=2024-01-12 |website=Visual Studio Blog |language=en-US}}</ref> === C++ === With default settings MSVC does not do two-phase name lookup which prevents it from flagging a wide range of invalid code. Most checks are deferred to template instantiation. More recent versions remedy this behavior, but it needs to be enabled by the command-line option <code>/permissive-</code>.<ref>{{cite web|url=https://devblogs.microsoft.com/cppblog/two-phase-name-lookup-support-comes-to-msvc/|title=Two-phase name lookup support comes to MSVC|date=2017-09-11}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)