As far as I understand:
provides the ability for the inclusion of header files, macro expansions, conditional compilation, and line control.
The one I'm concerned with is the inclusion of header files, it does so by replacing #include blabla.h
with the actual code of blabla.h
. And it is invoked before compiling.
takes one or more object files generated by a compiler and combines them into a single executable file, library file, or another object file.
Reading many answers here on StackOverflow, I understood that it "links" the other libraries whose functions I may be using in my code with my actual code, e.g., stdio.h
and printf();
. And it is invoked after compiling.
Now my question is, if the preprocessor has already --literally-- included that library's code in my code, why do we need linking? Assuming they've become one file.