Why is the Visual Studio Runtime Library source code stored in two directories?

There seem to be two paths containing the source files of the Microsoft Visual Studio runtime:

C: \ Program Files (x86) \ Microsoft Visual Studio 12.0 \ VC \ crt \ src

and

C: \ Program Files (x86) \ Microsoft Visual Studio 12.0 \ VC \ include

Some files appear in both directories, but have different sizes. I looked at one file in particular, and it had the same method defined in both files.

So my question is, what is the difference in usage for the two paths? I would like to know when I am debugging (I don't mean debugging mode) in Visual Studio, which file is the code on the screen?

+7
windows visual-c ++ visual-studio visual-studio-2013
source share
2 answers

A CRT is at the bottom of the Visual C ++ library stack: all other libraries depend on it, and almost all of its own modules depend on it. It contains two types of materials: [1] the standard C library and various extensions, as well as the functionality of the runtime environment [2], necessary for tasks such as starting a process and handling exceptions. Since CRT is at the bottom of the stack, the logical place is to start the library stabilization process.


(1) We ship most sources for CRT using Visual Studio; You can find them in the Visual Studio installation directory under VC \ crt \ src.

(2) In Visual Studio 2013 there are 6,830 #if , #ifdef , #ifndef , #elif and #else directives in the sources that we ship with the product; in Visual Studio "14" CTP there are 1,656. These numbers do not contain directives in the headers, and they include STL source files that are largely unaffected by this refactoring, so this is not an ideal measurement, but it does indicate the number of cleared operations that have been done.

EDIT 1:

Information about the article:

written by James McNellis

Date: 10 Jun 2014 9:00 AM

url: http://blogs.msdn.com/b/vcblog/archive/2014/06/10/the-great-crt-refactoring.aspx

+1
source share

The include directory has all the public headers. These are headers that you can include in your code, such as <stdio.h> and <type_traits> , as well as the implementation headers required by these headers.

The crt\src directory contains CRT sources, including most of the .asm , .c and .cpp files used to create CRTs. This directory also has a copy of many CRT headers, and in some cases these headers are different from what is in the include directory. This is just an artifact of how a CRT was built.

When debugging inline code defined in CRT headers, the debugger should always select the correct header. If both directories contain the same copy of the header, then the debugger simply selects one, and since the headers are the same, it does not matter which one it chooses. If the headers are different, then which header the debugger chooses depends on the object into which the built-in function was compiled. If the object is part of a CRT, you enter the header from crt\src ; if the object is from one of your source files, you enter the header with include . In principle, the debugger should always be able to find the correct copy of the header.

We have greatly simplified this in CTP Visual Studio "14". The crt\src directory no longer has public headers, and the headers sent to the include directory are the same as those used to build the CRT.

+9
source share

All Articles