summaryrefslogtreecommitdiffstats
path: root/md/notes/undefined_c/titles.md
blob: 11d5271bfc608efa213fbe9ebeaa12d069253017 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
title:Undefine C 
keywords:c,linux,asm 

# Undefined C

There is possible to piece of code inside online c compiler like https://www.onlinegdb.com/online_c_compiler
Or run locally

## Syntax

### Variables

Standard list of available types

#### Check type size

All types have size that are declared in bytes. Some of the types are machine dependents.
like int/long, if there is needed machine independent types then there are int32_t/uint32_t/int64_t/uint64_t

Each architecture 8bit/16bit/32bit/64bit will have different size for those types

Use __sizeof()__

Running on x86 machine
```c
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
int main() {
    printf("Sizeof int %lu\n",sizeof(int));
    printf("Sizeof int32_t %lu\n",sizeof(int32_t));
    printf("Sizeof int64_t %lu\n",sizeof(int64_t));
    printf("Sizeof long %lu\n",sizeof(long));
    printf("Sizeof long long %lu\n",sizeof(long long));
}
```

Defined macros'es to get type max and min values are

https://en.cppreference.com/w/c/types/limits

```c
#include <limits.h>
int main() {
    printf("INT_MIN %d\n",INT_MIN);
    printf("INT_MAX %d\n", INT_MAX);
    printf("LONG_MIN %ld\n",LONG_MIN);
}
```

#### How to shoot the leg

When code suppose to run on 32bit and 64bit platform the size of type may vary. n
Need to take in account this case.





### Functions



### If statement
### For cycle
### Structure
### Recursion  
### Macro
### Signed/Unsigned
### Endianess 
### Styles
### Compiler flags

## Base usage

### Kernel module
### Write plugins


### Intermediate usage

## Linking
### Creating shared library
### Create static libraries
### Join all objects together


## Embedding  

### Embed in C++
### Embed in Go
### Embed in Swift
### Embed in JS

### Lua in C
### Python in C


## Multiplatform

### Cross compile
### Different flags
### Check architecture
### ARMv8
### AVR8


## Graphics

### SDL2
### GTK
### OpenGL
### Generate image