sr-coding-style.txt 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # $Id$
  2. #
  3. # SIP-router Coding Style
  4. #
  5. # 2004-06-07 Andrei Pelinescu - Onciul <[email protected]>
  6. Important rules:
  7. ----------------
  8. - use tabs for identations
  9. - tabs are set to 4 spaces
  10. - break lines longer than 80 characters
  11. - don't use c++ style comments (//); they belong in c++-
  12. - don't declare variable inside blocks.
  13. e.g:
  14. if (){
  15. int i;
  16. or
  17. for (i=0; ...){
  18. int a;
  19. - declare functions as follows (braces placement):
  20. int function(int x)
  21. {
  22. /* body */
  23. }
  24. - try to avoid c99 specific stuff, it might not work with older compilers
  25. Not so important rules:
  26. -----------------------
  27. - don't declare and init variable in the same time (unless they are static or global)
  28. e.g.:
  29. use instead of int i=0;
  30. int i;
  31. /* ... */
  32. i=0;
  33. - with the exception of functions, put the opening brace on the same line
  34. and the closing brace aligned to the first character in the line:
  35. if (cond) {
  36. /* ...*/
  37. }
  38. - avoid mixed case naming for variables or functions
  39. - try to describe what a function does in a comment at the head of the function
  40. (try to document at least the return values)
  41. Doxygen
  42. -------
  43. - try to always add doxygen comments to functions and variables declared in your code.
  44. Especially remember to document public functions, functions and structures
  45. that are part of the SIP-router API.
  46. - each file needs a declaration of the purpose of the file in the \file section
  47. If you are editing someone elses code, try to use his coding conventions
  48. (unless they contradict with some of the above rules).