Why are "out of source" builds not the default?

I just found out recently that you can configure Visual Studio (but this question is the same for any compiler) to dump the intermediate .o files into a separate folder outside of the source tree, instead of alongside each individual project. That makes it easy to clean the project up to archive to zip or something along those lines.

Why is that kind of configuration not more common? Are there any significant downsides?


This is the default in Visual Studio, and has been for quite some time (at least as far back as VC++ 6). The intermediate directory defaults to the same as the output directory, not the source directory. This means that all object files are placed alongside the final output.

In fact, it requires some jiggery-pokery if you're working with projects that expect compiler output to be placed alongside source files. Since VC++ defaults to giving object files the same name as their corresponding source file (but with a different extension), if you have several source files with the same name (but different paths), then compilation of each source file will overwrite the corresponding object file. The last file to be compiled "wins".

This, naturally, breaks the build.

Requiring source filenames to be globally unique across a project is actually pretty annoying. You can alter the output location so that it for example includes a path; the linker still does the Right Thing.


This is probably a question with a history answer. The first C compilers (and thus the first C++ compilers) Were written on and for Unix. There is no 'standard' place for much of anything in unix, with only a few exceptions. As such, the normal practice is to just put everything in the current working directory, unless instructed otherwise.


I'm going to go with "because VS is developed in a vacuum, where ideas from the outside world don't often intrude. Organizing build files in this way worked acceptably in the first versions of Visual Studio (or its non-Studio precursors), and since that's the way it's always been done in-house, and no one ever came in from the outside and said "you know, the rest of the world would really like to separate intermediate junk files and their actual source code", the VS team never figured it was an issue.

It's just a guess, but I can't think of a better explanation.

链接地址: http://www.djcxy.com/p/46896.html

上一篇: 为什么输入和选择使用不同的盒子模型?

下一篇: 为什么“脱销”不是默认的?