C
last edited Sat, 29 Mar 2025 06:59:24 GMT
backlinks: null
C
This page does not cover topics relevant to C Plus Plus. Often dubbed a general-purpose or system programming language due to its close associated with the UNIX system.
How to C in 2016 direct link to this section
Modern solutions to modern problems in a not so modern programming language.[1]
- Don't write C if you can avoid it, follow modern rules if you must write C
- use standard types, not primitive types
#include <stdint.h>- char is not included due to misuse
- acceptable if pre-existing APIs requuire
char
- acceptable if pre-existing APIs requuire
- fast and least types
intcan be 16bits on some paltforms aand 32 bits on others, good luck edge testing every case if you choose to use int- okay if using a function with native return types
- char is not included due to misuse
- never use anything unsigned when
<stdint.h>is superior - use
intptr_tfor system dependent types - declare your
forloop counters in-line #pragma onceso headers only need to be included once- allow for static initialiation of auto-allocated arrays and structs
- use clang-format
- never use malloc, use calloc for performance impact [2]
Libraries direct link to this section
GNU C Library direct link to this section
Commonly referred to as glibc. Supports C++ and other languages.
MUSL direct link to this section
Another common implementation using the MIT license
Compiling direct link to this section
gcc -o p ./p.c
- compiling creates an object file
- linking process takes object file and outputs and executable or lib