From 4e3faca5cfba88423dc2f3638782a0eec4ed579d Mon Sep 17 00:00:00 2001 From: Aney Date: Sat, 3 Oct 2020 14:28:53 +0100 Subject: [PATCH] Added refernces for docker and C --- C/compiler.md | 39 +++++++++++++++++++++++++++++++++++++++ C/functions.md | 0 C/preprocessor.md | 27 +++++++++++++++++++++++++++ C/source_files.md | 31 +++++++++++++++++++++++++++++++ C/statements.md | 0 C/variables.md | 0 docker.md | 13 +++++++++++++ 7 files changed, 110 insertions(+) create mode 100644 C/compiler.md create mode 100644 C/functions.md create mode 100644 C/preprocessor.md create mode 100644 C/source_files.md create mode 100644 C/statements.md create mode 100644 C/variables.md create mode 100644 docker.md diff --git a/C/compiler.md b/C/compiler.md new file mode 100644 index 0000000..e5a3775 --- /dev/null +++ b/C/compiler.md @@ -0,0 +1,39 @@ +# Compiler + +To compile a C file run gcc on it + + gcc file.c + +This will create an output file called a.out + +To show all warnings in the compiler use -Wall + + gcc file.c -Wall + +To actually show all warnings -Wextra and -pedantic should also be used + + gcc file.c -Wextra -pedantic + +You can also change the standard of C, for example C99 which doesn't require a return in void functions + + gcc file.c -std=c99 + +These can also be used in conjunction + +# Output file + +To change the output file from a.out specify the name with the output flag + + gcc file.c -o outputName + + +# Single file compilation + +The compiler compiles one file at a time, generating an .obj file for each. + +# Linker + +To create a usable executable the .obj files need to be linked together. After compilation the linker will link these files together for use. + + + diff --git a/C/functions.md b/C/functions.md new file mode 100644 index 0000000..e69de29 diff --git a/C/preprocessor.md b/C/preprocessor.md new file mode 100644 index 0000000..86f7211 --- /dev/null +++ b/C/preprocessor.md @@ -0,0 +1,27 @@ +# Preprocessor + +The preprocessor comes before the compiler. + +It's job is to prepare the source code for compilation. + +Anything that begins with a `#` is for the preprocessor, such as includes + + #include + + #include "multiply.h" + +Which tells the compiler to compile these files together as one + +The preprocessor can also be used for macros + + #define SQUARE(x) multiply(x,x) + +Macros, when called aren't like typical functions, instead the preprocessor replaces the macro call with the code itself. + +`SQUARE(10)` would be replaced with `multiply(10,10)` + +They can generate allsorts of code, such as CONSTANTS + + #if LEVEL > 0 + /* conditionally do this code */ + #endif diff --git a/C/source_files.md b/C/source_files.md new file mode 100644 index 0000000..84aa246 --- /dev/null +++ b/C/source_files.md @@ -0,0 +1,31 @@ +# Source Files + +# Source + +Source files need to be declared in the source file it's called in. + +- main.c + int main(){ multiply(4,5); } + +- multiply.c + int multiply(int x, int y){ return x * y; } + +Definitions in multiple need to be declared in main to be called. + +Function declaration could be added to main.c above the main function, and this would allow for function calls. + +However multiply's functions may want to be used in multiple different source files + +# Header + +Header files are used for declaration so they can be used in other source files. + +- multiply.h + int multiply(int,int); + +This header file will then be added to the main.c source file, at the top. + +- main.c + #include "multiply.h" + +That will include the contents of the multiply header file to the source file. diff --git a/C/statements.md b/C/statements.md new file mode 100644 index 0000000..e69de29 diff --git a/C/variables.md b/C/variables.md new file mode 100644 index 0000000..e69de29 diff --git a/docker.md b/docker.md new file mode 100644 index 0000000..f24eba6 --- /dev/null +++ b/docker.md @@ -0,0 +1,13 @@ +# Docker + +# Make new container + +# Start/Stop containers + + docker start + + docker stop + +# Remove exisit containers + + docker rm