14.1 (conspect) Strings
Stages of converting a program in C to binary:
.c → (preprocessor / cc -E) → .c
.c → (translator / cc -S) → .s
.s → (assembler / cc -c) → .o
.o → (linker / cc or ld …) → binary
It creates not only code, but also possible functions, adds a main call, and stack protection.
Graph of dependency
Let's say the project consists of several files in C, then the entire structure of the binary build becomes inconvenient.
Example:
- Output function in a single file
- In another file, call the function
So you can compile both files and get the output. This is inconvenient because when there are a lot of them, it's a long operation and you don't always need to compile everything. If we want to compile a particular one separately, we bring all of them to the state of the objective and build the binary. If we edit only one of these two files, we need to compile it again, otherwise the object file will consist of the old ones, but when we update one, we only need to recompile it. Therefore, for convenience, you need to create a dependency graph.
Dependency graph- graph of files, which consists of files that each file goes and by what method it is obtained. Thus we use graph to rebuild faster, so that you can immediately see which file needs to be compiled again.
Makefile
There are in Makefile:
- Target
- Sources
- Recipe
Example:
We get a dependency chain and if the main file requires updating, the entire chain is updated. The build is defined automatically: it goes in any order and is self-defined, and the Make uses only the time.
Best example of realization:
Strings
Important
There no such data type as strings
As it usually works as an integer. There are special string converters and you can't put a Strings on the stack.