sr-coding-style.txt 1.5 KB

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