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();
The functions are implemented like this
void Do_A()
{
Do_B();
}
void Do_B()
{
Do_C();
}
void Do_C()
{
printf("Do 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
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).
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.