Add an index to the notes section

This commit is contained in:
2025-03-25 14:22:45 +00:00
parent e89a63e30c
commit 8e4530d3d2
8 changed files with 91 additions and 37 deletions

View File

@@ -7,19 +7,18 @@ tags:
- programming
author: TrudeEH
showToc: true
weight: "31"
---
Convert `C` code into machine code in 4 steps:
1. **Preprocessing** (Convert all preprocessor instructions: `#…`)
2. **Compiling** (Convert `C` code to machine code)
3. **Assembling** (Compile the necessary libraries)
4. **Linking** (Merge the compiled code with the compiled libraries)
A compiler converts `C` code into machine code in 4 steps:
1. **Preprocessing** (Convert all preprocessor instructions (`#…`) to C code.)
2. **Compiling** (Convert `C` code to assembly.)
3. **Assembling** (Compile the necessary libraries.)
4. **Linking** (Merge the compiled code with the compiled libraries.)
## Libraries
Libraries are pre-written collections of code that can be reused in other programs. On **UNIX* systems, they are usually located in the `/lib/` and `/usr/include` directories.
Libraries are pre-written collections of code that can be reused in other programs. On *UNIX* systems, they are usually located in the `/lib/` and `/usr/include` directories.
### Math.h
@@ -47,7 +46,7 @@ To use a library, we first have to include it in the `C` code.
#include <cs50.h> // cs50.h library will be included.
```
Then, the library must be linked at compile time.
Then, the library must be linked at compile time (unless it is part of the C standard).
```Shell
gcc -o hello hello.c -lcs50
@@ -75,6 +74,6 @@ clean:
```
```Shell
make #Compiles hello.c
make clean #Removes the executable (hello) generated by the make command.
make # Compiles hello.c
make clean # Removes the executable (hello) generated by the make command.
```