In this lecture I want to broadly go over how our programs get built.
So are able to run.
So there are three main steps that have to happen.
The first step is the preprocessing step.
The next is the compilation and the last step is the what's called blinking so the preprocessor effectively
replaces all the preprocessor Duret preprocessor directives in the program and paste the relevant info
into the files themselves.
So for example we have the line that I didn't cover before which says include IO stream.
So the hash include is actually a directive preprocessor directive that says make sure that IO stream
which is a part of the standard library has all the input and output it'll paste the entirety of IO
stream into our our program.
So that's why we're able to use things like C in and C out and actually output things and get things
from the console.
So after this is done the output of the preprocessor will be C++ files with absolutely no directives
so they'll be here C++ files.
And that goes into the next stage which is the compilation stage and the compilation stage will take
all of the C++ files as input and then turns them into assembly code and then machine code and place
them into these stored object files and U-Mass Why does it need to do this well.
The machine can't actually run C++ machine can only run machine code which is actually the native language
of the machine.
So that's why everything has to be compiled down even further from C++ into something that the machine
can understand.
Remember I said computers are kind of dumb so they don't really know many languages and only really
understand one.
And this is machine language and here's a picture of kind of how the compiler works it'll take all our
C++ files.
In this case not c files and all these other assembly files and put them into these object files these
relocatable object files
and those object files will be input into the linker.
We're not going to go over too much of the linker in this course but the linker takes all the object
files as input and really kind of bundles everything together.
Into our executable program it will take more than just our object files that take other things that
we're not going to go over.
But the idea is it will it.
It does the assembling and creates the real program.
Here's another diagram that sort of shows how this works.
So there's one other line in our program that we still don't understand which is the using namespace
SDD.
And this has kind of nothing to do with the compiler or linker but I thought I'd throw this in here
just to just for the sake of completeness really.
So this namespace SDD is a way of organizing code.
In fact just the namespace part of it and we use it because all of the identifiers which have all the
names of things in our IO stream library like scene and C out they all exist in the standard namespace
which is the standard library names.
So if we didn't write the using namespace SDD we'd actually have to write SDD colon colon C out in the
open colon C in so that Koehne colon is really says hey this object C Ouch belongs to this standard
namespace so hopefully that clears up a little bit of those two lines.
I want to sort of demystify them a little bit so that we can continue on and start learning about constants
next time.