Visual Studio以什么顺序编译源文件? [英] In what order does Visual Studio compile source files?

查看:146
本文介绍了Visual Studio以什么顺序编译源文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio 2012中有一个C ++库项目,带有这些文件

I have a C++ library project in Visual Studio 2012, with these files

A.h, A.cpp: defines function Do_A();
B.h, B.cpp: defines function Do_B();
C.h, C.cpp: defines function Do_C();

功能是这样实现的

void Do_A()
{
      Do_B();
}

void Do_B()
{
      Do_C();
}

void Do_C()
{
     printf("Do C");
}

在这里,我想强制A,B,C之间的依赖关系。

Here I want to force the dependency among A, B, C. Then I build.

但是在查看输出窗口时,我看到

But when looking at Output window, I see

A.cpp
B.cpp
C.cpp

为什么编译A第一?什么会影响源文件的编译顺序?

Why is A compiled first? What affect the compile order of source files?

推荐答案

该依赖关系是在链接时而不是编译时(因此不会显示)

That dependency is at link time, not compile time (thus won't show here).

构建脚本中的位置会影响编译顺序(除编译时间相关性外,没有其他假设),但这在一定程度上是不正确的因为构建可以并行化。也就是说,A和B可以同时建立在两个不同的内核上。

The position inside the build script is what affects the compile order (and there is no assumption on that, other than compile time dependencies), but that's partly untrue as build could be parallelized. That is, A and B could be built on two different cores, at the same time.

这篇关于Visual Studio以什么顺序编译源文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆