I noticed that I was able to compile a child class before a parent class with g++. Is there any need to compile in a specific order, with consideration to dependencies?
Each . c file is a separate compilation unit which is compiled independently of other compilation units. So the compilation order does not matter. But: each .
(debug) Inserting the `g' flag tells the compiler to insert more information about the source code into the executable than it normally would.
Each C++ source file needs to be compiled into an object file. The object files resulting from the compilation of multiple source files are then linked into an executable, a shared library, or a static library (the last of these being just an archive of object files).
Only those changed files need to be recompiled. Header files are not compiled directly, Instead, header files are included into other source files via #include .
In short: No!
Each C++ compilation unit (C++ source file) is compiled independently. Class inheritance etc is set up at runtime. This is why you can have base classes in separately maintained libraries that can be updated without forcing descendant classes to be recompiled, as long as the API and the ABI remains compatible.
Linking order can matter; compilation order does not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With