So let's explain external variables.
Copy what I'm doing.
So what we've done here we've created a global variable called ABC but we've marked it as external which
means that which which tells the compiler we're not creating a variable by here we're just letting you
know that there's a variable somewhere in our program called ABC that exists.
So if I was to do ABC equals 50 here and we were to compile that what would happen is you would see
undefined reference to ABC because we've said that this is somewhere else.
And when it comes to compiling we don't we haven't told you where ABC is.
So the compiler is thinking well you said you were going to tell me and you didn't.
So it basically fails to link and correct your executable binary that you file.
So let's define ABC then I want you to create a file called Test Odyssey and we're just going to go
integer.
ABC equals 50.
That's all I wanted to do.
And now what we're going to do is we're going to compile that file so you do GCSE test stuff see Dash
show test stuff.
Oh and do desk C so that's curated an object file called test.
Oh.
And now if we now do GCSE mandate C test o dash o Main and press enter you can see it now compiles absolutely
fine because by including the test o object we are telling the compiler where ABC is because we've we've
defined ABC here.
Right.
We've said insta ABC equals 50.
So then in Maine not see when we say external integer ABC what can the compiler.
We are aware of ABC but it isn't defined here.
Go and look for it when the time comes.
That's basically what we're saying.
And then obviously when we put it in our test or see fall here.
And we compiled it by here into a test.
Oh.
Object ABC is then stored in that object file.
Right.
So then when we go to compile our program completely and then we pass test.
Oh it links the two together resolve in the external ABC into the ABC that we know that we defined and
test all to see.
So that's how external variables work.
It allows you to Mark variables as outside of the source file and then we can resolve them later.