Hello and welcome.
And in this lecture we're gonna learn about the Prix process.
Now the Prix process is a compile time language built into C and it allows us to control the way things
are compiled.
So for example what I could do is I could say if death tests and if and then I could say void test.
Now if you compile this we won't have a functioning code test.
We we just won't have one because test is not defined to understand.
So the compiler will see this it will go through the code.
It will say is test defined.
No it isn't.
So let's not do what's in here.
That's what it will say.
Now if we do appear.
Define test then this code will be compiled not just to demonstrate this less to test here to call that.
And if I go up to here and to do that it compiles fine.
If I do mean it works fine.
Now get rid of defined tests here.
Try to compile that again.
And look what happens oh implicate declaration of function test and then it fails to link because the
compiler never bothered to compile test because test is not defined.
So hash tag if def means if the definition is defined and the definition what checking that was defined
is test.
So that's pretty straightforward right.
You can also do some pretty cool stuff with this like for example I can go define ABC 50 and now if
I went into a equals ABC A becomes 50.
So that's a brief overview of the process so far.
You can do much more complicated things with this such as allowing function arguments so I could do
something like ABC X and A and then I can do.
And then I could call a function here maybe so I could do um print f I.
Then I could go I again for two integers and then here I could go X and a right.
And now if you did ABC 5 and 10 and notice I didn't put a semicolon because I put one here and my definition.
But if you get rid of that then we should put a semicolon you get it.
So if you can pull that now can you run that.
You can see it says 5 10.
So what we've done here we haven't created a function.
This isn't a function right now.
We've created a kind of macro function pre process a function.
So this isn't an ABC here.
It's not actually compiled into our program at all.
What happens is the compiler comes in it says ah OK you want it.
So whenever anyone does ABC and passes two values we should instead replace this with print f and the
values that they entered.
So what happens is the compiler comes through it sees ABC 5 10 and then it replaces it with this line
eight.
It literally replaces it with that.
That's what it does.
And that's why if you put a semicolon here you don't have to put one here that exact reason because
it literally takes this replaces it with this and fills in the values.
So that's a brief overview of the that the Pre process is very good for things like checking checking
that certain values meet certain criteria is a compile time such as you know if you're doing kernel
development for example you might want to check the actual kernel version meets a certain bounds and
then you know you can do things like that at compile time.
So poor process is a very powerful tool and that is just a small example of what it can do.