Hello, and welcome. In this lecture, I want to talk about the preprocessor.
We briefly discussed this concept in earlier lectures,
mainly just citing it as an advantage.
The main reason I want to talk about it a little right now early in class
is because it's being used in every single program.
And I want to talk about the include directive, which is a preprocessor command.
So if I want to talk about that, I first have to describe the preprocessor
in general. This is going to be a high-level description.
As we go through class, we'll talk about more of the preprocessor
in terms of its different directives and so on.
But to just understand the basics,
this preprocessor is a unique feature of c.
It's not found in many other languages.
And it's very advantageous, and you should try to understand it.
And we should try to use as much as possible.
It basically allows for programs to be easier to develop by the developer.
It makes programs easier to read. It makes them easier to modify and it makes them easier to port.
So it allows for a lot of advantages.
And so to have a description understand what it is in an early
learning of c is important.
It's part of the c compilation process,
but it's recognized as special statements.
And just like it says preprocessor in the name,
it implies that something's going on before you process the code.
So analyzes certain statements in your code
before it actually analyzes the program itself.
It does things before it compiles, essentially.
So it's telling your compiler that, hey, before you actually convert
into this code, before you generate the object files,
before you generate and do all the linking and generate the executable,
first do this.
And so because you do this stuff before you compile,
you can optimize things and you can make things a lot easier.
Now you'll often have these preprocessor commands
at the very top of your source code,
but they can be anywhere. They can be anywhere interspersed throughout your code.
One of the big ones that we're going to talk about is the include.
So the way that you can identify preprocessor statements in your source code
is they have a pound sign before them,
so they have that number pound sign.
And that has to be the first non-space character on the line
in order to be a preprocessor command,
also known as a preprocessor directive.
Now as I mentioned, our first challenge actually used a preprocessor directive.
It was the include directive. We know it's a preprocessor directive because we saw the pound symbol.
We don't exactly know what the include does, we'll talk about that in another lecture.
But it is a preprocessor command, it is a preprocessor directive.
And again, because it's used so widely basically,
in every program because every program is going to have an include,
I wanted to talk about it early on.
But it doesn't just mean that there's an include.
The pre-processor can do many, many other things and have other commands.
Some of the things we'll talk about as we go through this course concerning the preprocessor
are things like being able to create constants. Constants is a concept
where it's a variable essentially that never changes its value.
It's data that never changes, that's how you can think about it because we haven't even talked about variables yet.
But you can create
constants in the preprocessor and this optimizes your code makes it more efficient and runs faster.
There's also this concept of a macro which is an entire another topic in itself.
But a macro is another preprocessor directive.
And the way that you can create the macros is you can use the define statement.
And so we'll talk about the define, we'll talk about creating constants.
But you should be familiar with this preprocessor
concept and utilizing these different things like include,define, constant.
Include, we'll talk about specifically in the next lecture,
but a benefit of this is that you can create your own library files.
And we talked about what a library is, a library is just reusing existing code.
So it's code that you don't have to write.
The c programming languages comes with its own standard library
that does many things for you,
like display output to the console, read and write files,
handle streams, all sorts of different things. If you're familiar with java,similar
importing java APIs,
application programming interfaces.
Other examples of a preprocessor directive would be conditional
conditional things, like the if def the end if,
the else or the in if not define statements,
and we'll talk about those in more detail as well.
But all these preprocessor directives help with
the efficiency of the code, and they run before the compiler actually runs.
It's run before any code is
has generated any object files or executable files.
But we'll cover all this in much more details in future lectures.
I wanted to give you a little, little taste of it
beforehand because we need to understand it before we can understand
what we're doing with the include statement which is what we're going to talk about next. Thank you.