README.coding.style 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. Writing FB code every coder should keep in mind these rules:
  2. - Configure your editor to use 4 position for tabstop.
  3. - indent: 1 tab
  4. - space after e.g. if/for/while/switch - do "if (", not "if(".
  5. - no spaces allowed between function name and leading left paren - do
  6. "foo()", not "foo ()".
  7. - spaces around operation - do "c = a + b;"
  8. - spaces between function's parameters
  9. - no spaces with pointer sign - do "*p++ = *q++" and "char *a".
  10. - Mandatory braces around scoped code. Closing brace always aligned to the
  11. first char of the keyword introducing the scope - i.e.
  12. if (foo) {
  13. // code
  14. }
  15. or
  16. if (foo)
  17. {
  18. //code
  19. }
  20. first form is not allowed if condition exeeds one line. Braces may be omitted
  21. only if condition doesn't exceed one line and conditional statement also doesn't
  22. exceed one line.
  23. - No spaces in C++ cast expressions. Do "static_cast<type*>(ptr)", not
  24. "static_cast < type * > ( ptr )".
  25. - Prefer to keep lines shorter than 80 chars.
  26. - Prefer initialization over assignment.
  27. - Don't break the build. Before commiting do full build cycle from
  28. scratch (on all available platforms).
  29. - Always end source files, including headers, with a newline.
  30. - Prefer C++ style for comments
  31. - Use abstract datatypes (UCHAR, SSHORT, ULONG etc) instead of generic
  32. ones (unsigned char, short, unsigned long resp) because generic types
  33. can be changed unexpectedly (long int become 64 bits for example).