After researching a bit on compilers and how they work I learned that the process is often broken up into 4 steps: Preprocessor, Compiler, Assembler and Linker. The way I envisioned these steps was each being it's own separate program; A preprocessor program, a compiler program, an assembler program and a linker program. However, you learn that sometimes the process of creating assembly code and generating object files is all handled by the compiler program and sometimes its not. It seems to depend very much on the context and programming language used. My question is then how is the typical translation process broken up for translating C++ source code into machine code?
- Is the preprocessor a separate program from the compiler? Or is that process usually a part of the compiler program?
- What is the compiler typically responsible for? Generating assembly code and then conversion to machine code?
- Is the linker it's own separate program that is run after the compiler finishes?
Side note: My question is different from other C++ compiler threads because I'm asking not only how a compiler works but if certain other processes, such as linking, are there own executable programs or if they are typically built into a compiler program.