ocochard / C

C exercices

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

C coding

Ressources

Some ressources online:

Tips & Tricks

Default compiler option

During dev:

cc -g3 -Wall -Wextra -Wconversion -Wdouble-promotion -fsanitize=undefined -fsanitize-trap

Or:

cc -std=c11 -pedantic

Formating

  • indent
  • clang-format

Types

Which type is time_t on my OS ?

echo | cc -E -xc -include 'time.h' - | grep time_t

On x64 FreeBSD it is a int64_t:

typedef __int64_t __time_t;
typedef __int64_t __sbintime_t;
typedef __time_t time_t;
(etc.)

On 32bit FreeBSD it is a int32_t:

typedef __int32_t __time_t;
typedef __time_t time_t;
 time_t tv_sec;
(etc.)

On x64 Linux it is a long:

typedef long int __time_t;
# 1 "/usr/include/x86_64-linux-gnu/bits/types/time_t.h" 1 3 4
# 10 "/usr/include/x86_64-linux-gnu/bits/types/time_t.h" 3 4
typedef __time_t time_t;
(etc.)

About

C exercices


Languages

Language:C 86.8%Language:Makefile 13.2%