0

According to this answer : https://stackoverflow.com/a/6264256/1870760 compilation is done in three steps:

  • preprocessing
  • compilation
  • linking

Now let's say I have a project in Visual Studio with multiple source files and I start building the entire project, how is this processed?

Is it:

  • Preprocess source file #1
  • Compile source file #1
  • Preprocess source file #2
  • Compile source file #2

etc.. and finally..

  • Link all object files

Or rather:

  • Preprocess every source file
  • Compile every source file
  • Link all object files

Or something completely different? Is this compiler specific or is there some general rule?

Community
  • 1
  • 1
Hatted Rooster
  • 35,759
  • 6
  • 62
  • 122
  • 2
    It's compiler specific. In practice, the lines are a lot more blurred than this. I don't think there's much merit in trying to figure it out. – Lightness Races in Orbit Sep 19 '15 at 13:01
  • Generally there's only *two* steps performed by the user: Compilation to object files and linking, and it can even be combined to only one step. However, the full process behind the commands one uses is a lot more complicated, I suggest you see e.g. [this compilation phase reference](http://en.cppreference.com/w/cpp/language/translation_phases). – Some programmer dude Sep 19 '15 at 13:08
  • Some compiler may even preprocess and compile all files in different threads and then link them all together in the end.....who cares!? – jpo38 Sep 19 '15 at 13:08
  • 1
    And let's not even bring preprocessed headers and others into this. Oops, I just did... – Sami Kuhmonen Sep 19 '15 at 13:51

0 Answers0