Added refernces for docker and C

master
Aney 5 years ago
parent f5cfb83475
commit 4e3faca5cf

@ -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.

@ -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 <stdio.h>
#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

@ -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.

@ -0,0 +1,13 @@
# Docker
# Make new container
# Start/Stop containers
docker start <container>
docker stop <container>
# Remove exisit containers
docker rm <container>
Loading…
Cancel
Save