I have a workspace containing many *.c files, which I compile. (I could use any toolchain say MSVC6.0, or gcc etc)
Which source file is compiled first?
How is the order of the files to be compiled subsequently decided?
I have a workspace containing many *.c files, which I compile. (I could use any toolchain say MSVC6.0, or gcc etc)
Which source file is compiled first?
How is the order of the files to be compiled subsequently decided?
VC: By project folder, then alphabetically.
GCC: according to the make file order
Why is this important?, the completion order don't meter and doesn't effect the final build result.
Generally, this is not specified anywhere. Especially when using eg. parallel make, the order of compilation is pretty much arbitrary.
With make
:
As jpalecek suggests, concurrent builds may be more complicated.
Some quotes from the GNU make docs:
The double-colon rules for a target are executed in the order they appear in the makefile.
...
If you specify several goals, make processes each of them in turn, in the order you name them.
The order of compilation is not specified by the C standard.
Since there is no need for the construction of global objects like in C++, there is no situation where the order of compilation is relevant in C.
If it matters then you really need to set dependencies in your makefile to ensure some are built before others. Really you should first ask yourself why it matters.