2 In general, use the same coding style as the surrounding code.
4 However, do not make any unnecessary changes as that complicates
5 the VCS (git) history and makes it harder to merge patches. So
6 do not modify code just to make it conform to a coding style.
10 Turn on a "fill tabs with spaces" option in your editor.
12 Remove tabs and trailing spaces from any lines that are modified.
14 Note that some files are indented with 2 spaces (when they
15 have large indentation) while most are indented with 4 spaces.
19 TCC is mostly implemented in C90. Do not use any non-C90 features
20 that are not already in use.
22 Non-C90 features currently in use, as revealed by
23 ./configure --extra-cflags="-std=c90 -Wpedantic":
25 - long long (including "LL" constants)
27 - very long string constants
28 - assignment between function pointer and 'void *'
30 - empty macro arguments (DEF_ASMTEST in i386-tok.h)
31 - unnamed struct and union fields (in struct Sym), a C11 feature
35 A simple "make test" is sufficient for some simple changes. However,
36 before committing a change consider performing some of the following
39 - Build and run "make test" on several architectures.
41 - Build with ./configure --enable-cross.
43 - If the generation of relocations has been changed, try compiling
44 with TCC and linking with GCC/Clang. If the linker has been
45 modified, try compiling with GCC/Clang and linking with TCC.
47 - Test with ASan/UBSan to detect memory corruption and undefined behaviour:
53 cp libtcc.a libtcc.a.hide
56 ./configure --extra-cflags="-fsanitize=address,undefined -g"
58 cp libtcc.a.hide libtcc.a
61 - Test with Valgrind to detect some uses of uninitialised values:
66 # On Intel, because Valgrind does floating-point arithmetic differently:
67 ( cd tests && gcc -I.. tcctest.c && valgrind -q ./a.out > test.ref )
68 make test TCC="valgrind -q --leak-check=full `pwd`/tcc -B`pwd` -I`pwd`"
70 (Because of how VLAs are implemented, invalid reads are expected
71 with 79_vla_continue.)