Developer C Coding Standard
From The Neuros Technology Wiki
Developer Coding Standards
Here we will outline the standards for "Hacking the Duck" when using the C programming language.
This is an attempt to make sure that the code remains maintainable.
Why do we need coding standards?
All developers have their own standards and layouts that they like to use. Therefore, when many developers work on the same source code it is likely that they will all attempt, in one way or another, to impose their style on the underlying code. However, if you enforce a coding standard on all developers this will not happen and the source code will remain easier to read and maintain.
Follow the leader
Provided code style remains consistent within a source file, the actual coding style used is flexible. In other words, discussed as "The Xiamen team's standard":
- Respect whatever standard is there when modifying existing code (bracing, tabbing, spacing).
- Follow whatever standard for tabbing, bracing and spacing, that makes most sense to you when creating new files.
- Naming conventions MUST follow the of the module's that you're adding the file to.
If a patch is submitted that doesn't follow these rules, then it WILL be rejected.
Why this method?
Code style is one of the all time holy wars that will never be resolved - however strongly people feel their style is "correct". This method of styling allows people to work with their own style where ever possible and should hopefully minimise time wasting associated with such wars.
Vim modelines are a method of storing code style within a file, so that future developers need not examine the file for the specific tabbing style used therein. It looks a little something like this:
// expand tabs to spaces, tab stop is 2 // vim:et:ts=2 // don't expand tabs to spaces (no need to specify tab stop) // vim:noet
These are incredibly useful for vim users, so feel free to add them when editing source files. The operating system masquerading as a text editor has a similar feature under the name File Variables.