36 lines
1.4 KiB
Markdown
36 lines
1.4 KiB
Markdown
# The goal being to be able to understand C code, rather than writing it effectively.
|
|
## C preprocessor
|
|
Produces a new file that compiler will process. Command to preprocessor start line with a # symbol as the first non-whitespace character.
|
|
|
|
\#include : use to pull the contents of one file into the current source file.
|
|
|
|
For ex to pull the entire content of `multiprocessing.h` :
|
|
|
|
```
|
|
#include "multiprocessing.h"
|
|
```
|
|
|
|
\#define : lets you define a new symbol that gets replaced with a text string .
|
|
|
|
For ex. `#define SEM_FAILED NULL` replace every instance of `SEM_FAILED` with the literal string `NULL` before the code is sent to the compiler.
|
|
|
|
\#under : erases any previous preprocessor definition from \#define. You can have \#define effect only a section of the file.
|
|
|
|
\#if : conditional statements, which allow to include/exclude certain sections of the text based on certain conditions.
|
|
|
|
There are three basic forms of \#if in CPython source:
|
|
|
|
1. \#ifdef <macro\> includes the subsequent text-block if the macro is defined.
|
|
2. \#ifndef <macro\> includes the text-block if the specified macro is not defined.
|
|
3. \#if <macro\> includes the text-block if macro defined and True.
|
|
|
|
\#pragma : instructions or hint to the compiler. Usually deals with how code is compiled not how it runs.
|
|
|
|
\#error : displays a message and cause the preprocessor to stop executing.
|
|
|
|
### Preprocessor directives
|
|
|
|
### C syntax compared to python.
|
|
|
|
### Loops, functions and strings.
|