Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. In general, use the same coding style as the surrounding code.
  3.  
  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.
  7.  
  8.     Indentation
  9.  
  10. Turn on a "fill tabs with spaces" option in your editor.
  11.  
  12. Remove tabs and trailing spaces from any lines that are modified.
  13.  
  14. Note that some files are indented with 2 spaces (when they
  15. have large indentation) while most are indented with 4 spaces.
  16.  
  17.     Language
  18.  
  19. TCC is mostly implemented in C90. Do not use any non-C90 features
  20. that are not already in use.
  21.  
  22. Non-C90 features currently in use, as revealed by
  23. ./configure --extra-cflags="-std=c90 -Wpedantic":
  24.  
  25. - long long (including "LL" constants)
  26. - inline
  27. - very long string constants
  28. - assignment between function pointer and 'void *'
  29. - "//" comments
  30. - empty macro arguments (DEF_ASMTEST in i386-tok.h)
  31. - unnamed struct and union fields (in struct Sym), a C11 feature
  32.  
  33.     Testing
  34.  
  35. A simple "make test" is sufficient for some simple changes. However,
  36. before committing a change consider performing some of the following
  37. additional tests:
  38.  
  39. - Build and run "make test" on several architectures.
  40.  
  41. - Build with ./configure --enable-cross.
  42.  
  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.
  46.  
  47. - Test with ASan/UBSan to detect memory corruption and undefined behaviour:
  48.  
  49. make clean
  50. ./configure
  51. make
  52. make test
  53. cp libtcc.a libtcc.a.hide
  54.  
  55. make clean
  56. ./configure --extra-cflags="-fsanitize=address,undefined -g"
  57. make
  58. cp libtcc.a.hide libtcc.a
  59. make test
  60.  
  61. - Test with Valgrind to detect some uses of uninitialised values:
  62.  
  63. make clean
  64. ./configure
  65. make
  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`"
  69.  
  70.   (Because of how VLAs are implemented, invalid reads are expected
  71.   with 79_vla_continue.)
  72.