Now let's embark on the compilation process, which begins with a set of source files that you intend
to compile.
So while it is possible to have just one source files, larger programs typically consist of multiple
files.
So this approach not only facilitates project management but also accelerates compilation.
So if a single file undergoes changes, you only need to recompile that specific file instead of the
entire code base.
So this C source file contains macros indicated by hashtag define.
Now we will create open the notepad here and we will create some define here.
So this is the C file.
Macro here, so we will save it as a C main dot, my app dot C and here, as you can see here, Mousepad
indicated that this is something that has macro and write it it on color font.
So and we also have the include here.
So the include directive here are used to incorporate header files with dot h extensions that the source
files relies on.
So during the preprocessing phase, these derivatives are expanded resulting in pure C that is ready
for compilation.
So to illustrate this process, let's examine an example application using the g c c compiler, which
serves as a default compiler in many Linux distributions and including Ubuntu.
The operating system installed on um.
Uh, more that like the most popular operating system in Linux, but in Linux you will also get that
GCC compiler here.
So it's important to keep in mind that the results obtained from other compilers like Clang or Visual
Studio will be similar.
As I mentioned earlier, I'll code examples in this course will be compiled into 8664 code unless specified
otherwise.
So now we will.
Chris Scott.
And which firstly we will include the include the studio hatch because we will need that for print here.
And after that we will define.
Define.
Format string.
And this format string is going to be s, as you know.
And we will also define.
Define message.
And it's going to be.
Hello.
Hello, world.
And after that we will create integer Main here.
And this integer XY here character.
Is here.
And after that we will print use the print function.
Printf.
Here.
First we will pass the format string.
And after that we will pass the message, which is Hello, world traditional message here.
And after that we will return zero.
Let's close the braces here.
That's it.
And in a moment here, you will see what happens with this file in the rest of the compilation process.
But for now, we will just consider the output of the preprocessing stage.
So by default, GCC will automatically execute all compilation phases, so you have to explicitly tell
it to stop after preprocessing and to show you intermediate output.
Right.
We will tell the GCC that and.
Here for GCSE.
This can be done using the common GCSE.
Let's clear here.
So gcse uppercase e parameter and p parameter.
So where e here tells GCSE to stop after pre-processing and P here causes the compiler to omit the debugging
information so that the output is a bit cleaner.
Right.
So here we will write GCC.
E p And after that we all sorry, we need to go to desktop because we saved this file in desktop.
And here let's LZ Oops.
Let's save it on desktop here.
And here.
Here we have my apk and clear so gcc e p and after that we will pass our file which is named my APK.
My apps.
And here it is.
So.
This is preprocessing phase here and we have this information.
So the studio dot h heater is included, included in this entirety with all of its type definitions,
global variables and functions, prototypes copied in to the source files.
So because this happens for every include directory directory here directive and let's actually copy
that.
And we will copy that right now and we will paste and analyze it further.
New.
And that's it.
And here we have integer Main here.
So.
And the preprocessor also really expands our use of any macros you define using, define.
And in this example, this means both arguments here, the format string and here the format string
and message are evaluated and replaced by the constant strings that they represent here.
But strangely, we don't have the format string format, string.
So we have this one.
Mistyped this string here.
And if you try to do that, like generally usually compile this my apk, we will get an error here because
we have this string not defined properly because of the.
Vermis.
Yeah, that's it.
And now if we compile this, this will compile without problem.
And let's run this again.
And here, as you can see, here we are seeing s and hello world here.
Now, let's.
And as you can see here.
This means that both arguments to printf which is.
Format, string and message are evaluated and replaced by the constant strings that they represent.
So this was the preprocessing phase of C and compiled languages.
And in next lecture we will also learn the compilation phase.
So I'm awaiting you in the next lecture.