icp/oer/courses/c-basics/sections/01-introduction/02-compiler/content.html

32 lines
1.8 KiB
HTML

<p>
You may have heard, that C is a <b>compiled language</b>. But what does that mean?
Basically programming languages can be categorized into two classes. Compiled and Interpreted.
An interpreted language will be interpreted at run time by another program, which will then send the necessary commands to the CPU to do, what you specified.
Examples for that, are languages like Python and Perl.</br>
C on the other hand is a compiled language. That means we have a program, the compiler, which <b>turns your code into executable binaries</b>.
These can be run directly by the CPU without any overhead.
</p>
<p>
A compiler consist of multiple stages. First comes the lexer. It turns all the meaningless characters into tokens,
which have meaning to the compiler. Then these tokens get parsed, to build the syntax-tree.
With the syntax-tree the compiler can start code generation. This code can then be optimized by the optimizer,
if you choose so. Bare in mind, that optimized code can be harder to debug.
</p>
<p>
On top of that C has the <b>preprocessor</b>. It touches the code before the compiler gets it. It is used for macros,
including header-files and other stuff <b>to prepare your code for compilation</b>.
</p>
<p>
In this course you will not see the compiler, because we want you to concentrate on learning C.
But if you are done with all the lectures, you should download one of the many compilers.
We are using GCC and compiling for the c99 standard. But feel free to experiment with other compilers like Clang.
<p>
<p>
A simple compile command in a command line with gcc could look like this:<br>
<code>gcc -std=c99 -o &lt;program_name&gt; &lt;source_code_file&gt;.c</code>
For further information read the <a href="https://gcc.gnu.org/onlinedocs/gcc-6.2.0/gcc/C-Dialect-Options.html#C-Dialect-Options">GCC-Documentation<a>.
</p>