Difference between revisions of "Code Styling Tips"
From eLinux.org
(→Proper Linux Kernel Coding Style) |
(→use of #ifdefs) |
||
| Line 12: | Line 12: | ||
Read: http://www.chris-lott.org/resources/cstyle/ifdefs.pdf | Read: http://www.chris-lott.org/resources/cstyle/ifdefs.pdf | ||
| − | |||
Personally, I tend to have symbols #defined to a constant 0 or 1 depending on | Personally, I tend to have symbols #defined to a constant 0 or 1 depending on | ||
Revision as of 22:28, 30 May 2008
Here are some miscellaneous tips for good code styling:
Proper Linux Kernel Coding Style
See the kernel coding style guide in any kernel source tree at: Documentation/CodingStyle
Greg Kroah-Hartman wrote some additional tips in his article: Proper Linux Kernel Coding Style
use of #ifdefs
Rob Landley writes:
Read: http://www.chris-lott.org/resources/cstyle/ifdefs.pdf
Personally, I tend to have symbols #defined to a constant 0 or 1 depending on whether or not a function is enabled, and then just use if(SYMBOL) as a guard and let the compiler's dead code eliminator take it out for me at compile time (because if(0) {blah;} shouldn't put any code in the resulting .o file with any optimizer worth its salt. Borland C for DOS managed simple dead code elimination 20 years ago...)