25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

96 lines
1.9 KiB

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