title:Undefined C
keywords:c,linux,asm
# Undefined C
There is possible to run piece of code inside online c compiler like https://www.onlinegdb.com/online_c_compiler
Or run locally. With base check is done with gcc compiler. There are many small tricks around running C code
in practice that aren't covered in any generic tutorials, so here is list of topics that may arise while
coding real C code outside of tutorials. For each case there is just small example, each of those could
take whole chapter on its own.
## Compile
__hello_world.c__
```c
int main() {
printf("Hello world\n");
}
```
```bash
gcc hello_world.c -o hello_world
gcc -m32 hello_world.c -o hello_world_32 #for 32bit target
```
## 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));
}
```
Most safest/portable way is to use [u]int[8/16/32/64]_t types.
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);
}
```
Example from AVR __stdint.h__
https://github.com/avrdudes/avr-libc/blob/main/include/stdint.h
Example from
|