gamefreak2291 wrote:I know it processing the c++ code, converts it into machine code, creating object files, and then links them into the executable
gamefreak2291 wrote:The thing I did not understand was how the final product would run if there were multiple sources
This is a contradiction...
You miss some aspects of the first point that makes you not having a proper understanding the second.
I try to summarize in brief:
- Each cpp file is a set of declaration that can be either object instances (aka "global variables") or function ("sequence of expressions and statements") each having a name.
Some of those declaration are "external" other "internal" (by default, functions are "external", tgat means "visible outside the file they are in")
- The translation the compiler does on each cpp file produces obj files where code is translated into machine code, and where external names are mapped in a symbol table.
- The linker peeks all the obj-s and libraries and resolve the mapped names with their respective references they have.
To let this process to succeed, all linked names must be unique (or mangled as such).
One of the names (corresponding to the
main function)is then mapped in the exe file as the "applicaion entry point" (well, not exacly, the entry point is an internally CRT initializer that calls main at the end...) so that when the operating system loads the application the execution will start from there.
If you follow these three steps, there is no reason why your question should take place.
The program flows in the way the various functions reciprocally call each other. No matter where they originally came from.
There is no "parallelism" in a C++ classic program.
2 bugs found.
> recompile ...
65534 bugs found.