選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

style.dox 2.1 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /** \page libcaca-style Libcaca coding style
  2. \section sty1 General guidelines
  3. A pretty safe rule of thumb is: look at what has already been done and
  4. try to do the same.
  5. - Tabulations should be avoided and replaced with \e eight spaces.
  6. - Indentation is generally 4 spaces.
  7. - Lines should wrap at most at 79 characters.
  8. - Do not leave whitespace at the end of lines.
  9. - Do not use multiple spaces for anything else than indentation.
  10. - Code qui fait des warnings == code de porc == deux baffes dans ta gueule
  11. \section sty2 C coding style
  12. Try to use short names whenever possible (\c i for indices, \c w for width,
  13. \c cv for canvas...). Macros are always uppercase, variable and function
  14. names are always lowercase. Use the underscore to separate words within
  15. names:
  16. \code
  17. #define BROKEN 0
  18. #define MAX(x, y) ((x > y) ? (x) : (y))
  19. unsigned int x, y, w, h;
  20. char *font_name;
  21. void frobulate_every_three_seconds(void);
  22. \endcode
  23. \c const is a \e suffix. It's \c char \c const \c *foo, not \c const \c char
  24. \c *foo.
  25. Use spaces after commas and between operators. Do not use spaces after an
  26. opening parenthesis or before a closing one:
  27. \code
  28. a += 2;
  29. b = (a * (c + d));
  30. x = min(x1, x2, x3);
  31. \endcode
  32. Do not put a space between functions and the corresponding opening
  33. parenthesis:
  34. \code
  35. int function(int);
  36. \endcode
  37. A space can be inserted after keywords such as \c for, \c while or \c if,
  38. but consistency with the rest of the page is encouraged:
  39. \code
  40. if(a == b)
  41. return;
  42. if (p == NULL)
  43. \endcode
  44. Do not put parentheses around return values:
  45. \code
  46. return a + (b & x) + d[10];
  47. \endcode
  48. Opening braces should be on a line of their own, aligned with the
  49. current block. Braces are optional for one-liners:
  50. \code
  51. int function(int a)
  52. {
  53. if(a & 0x84)
  54. return a;
  55. if(a < 0)
  56. {
  57. return -a;
  58. }
  59. else
  60. {
  61. a /= 2;
  62. switch(a)
  63. {
  64. case 0:
  65. case 1:
  66. return -1;
  67. break;
  68. default:
  69. return a;
  70. }
  71. }
  72. }
  73. \endcode
  74. \section sty3 C++ coding style
  75. Nothing here yet.
  76. */