coding_style.1 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. .TH "INTI C CODING STYLE" 1 "14 Jan 21"
  2. .SH INTRODUCTION
  3. This is the inti C Language Coding Style standard. Everybody in the inti (inti's not interpreters) should
  4. read this carefully and use it in their code which will commit to inti softwares.
  5. Most of this standard copies from K&R (THE C PROGRAMMING LANGUAGE), but some of them are different.
  6. .SH NAMES
  7. \fBALWAYS\fP use names with '_' and \fBNEVER\fPuse NamesLikeThis. We use names like both BSD and linux, but
  8. \fBNEVER\fP like Windows! Remember that here is C, not Java or other. And here is UNIX, not Windows. :-)
  9. For some long words such as \fBattribute\fP and \fBsystem\fP, you should make them short and let them look
  10. like \fBattr\fP and \fBsys\fP.
  11. And if the name is not so long, don't use '_' to split. This is what we usually do in BSD and POSIX.
  12. And, don't use some stupid words such as 'my' --- it makes your code dirty :-)
  13. \fBGOOD\fP: \fBi\fP, \fBp\fP, \fBname\fP, \fBp\fP, \fBattrmask\fP
  14. \fBBAD\fP: \fBattribute_mask\fP, \fBerror_number\fP, \fBget_my_name\fP
  15. \fBBADEST\fP: \fBIsSuccess\fP, \fBNameOfEveryStudent\fP, \fBMyStudentIdentify\fP
  16. .SH TABS
  17. \fBALWAYS\fP use tab8 instead of spaces. Right, spaces are more easy to port but it makes code big. And
  18. I think tab is a tradition of C, is that okay?
  19. .SH DECLARES
  20. You can use tabs after types and you can also don't. These are okay:
  21. \fBGOOD\fP: \fBint id;\fP
  22. \fBchar *name;\fP
  23. \fBGOOD\fP: \fBint id\fP
  24. \fBchar *name\fP
  25. Before, I didn't use tabs after types because my first was python and it brings me a lot such as '{}' at
  26. end of line and don't use tabs. But after reading the tyt code from linux 0.0.1, I relize it is more beatiful
  27. and I start to try. You can use tabs, but you should use them at the right place.
  28. .SH '{}'s
  29. You can use them as you want, but \fBNEVER\fP put '{}'s at next line after \fBif\fP or \fBwhile\fP etc.