Coding style documented.
This commit is contained in:
parent
9e0751fa2e
commit
be520e527a
|
@ -0,0 +1,58 @@
|
|||
Coding Style
|
||||
============
|
||||
|
||||
Those are a few notes describing my preferred coding style and thus the one to
|
||||
be used in idpc. Basically it is similar to the Linux kernel coding style (and
|
||||
to Kernighan and Ritchie).
|
||||
|
||||
|
||||
Indentation
|
||||
-----------
|
||||
|
||||
Tabs are 8 characters, and thus indentations are also 8 characters.
|
||||
There are heretic movements that try to make indentations 4 (or even 2!)
|
||||
characters deep, and that is akin to trying to define the value of PI to
|
||||
be 3.
|
||||
|
||||
-- Linux CodingStyle
|
||||
|
||||
|
||||
Long lines
|
||||
----------
|
||||
|
||||
Ideally everything should fit in 80 columns *but* this is sometimes impossible
|
||||
when you have to deal with libraries that use really long names for constants
|
||||
or functions; for example::
|
||||
|
||||
lasso_identity_get_next_federation_remote_providerID
|
||||
|
||||
Facing those names do at best.
|
||||
|
||||
|
||||
Braces and spaces
|
||||
-----------------
|
||||
|
||||
Use braces and spaces as told by K&R. And don't parenthesize things
|
||||
unnecessarily.
|
||||
|
||||
Also, Remember, return is the exact antonym of function call; it doesn't need
|
||||
parentheses; ``return 0;`` will do while ``return (0);`` or (even worse)
|
||||
``return(0);`` won't.
|
||||
|
||||
|
||||
Editors
|
||||
-------
|
||||
|
||||
Read the Linux CodingStyle document if you believe in Emacs and want to use
|
||||
sane values for its C formatting.
|
||||
|
||||
|
||||
References
|
||||
----------
|
||||
|
||||
- Linux Kernel Coding Style
|
||||
http://lxr.linux.no/source/Documentation/CodingStyle?v=2.6.5
|
||||
- comp.lang.c Frequently Asked Questions
|
||||
http://www.eskimo.com/~scs/C-faq/top.html
|
||||
- Notes on Standards and Style for Coding in ANSI C
|
||||
http://www.jetcafe.org/~jim/c-style.html
|
Reference in New Issue