Please note that User Registration has been temporarily disabled due to a recent increase in automated registrations. If anyone needs an account, please request one here: RequestAccount. Thanks for your patience!--Wmat (talk)
Please email User:Wmat if you experience any issues with the Request Account form.

Difference between revisions of "Code Styling Tips"

From eLinux.org
Jump to: navigation, search
Line 1: Line 1:
 
Here are some miscellaneous tips for good code styling:
 
Here are some miscellaneous tips for good code styling:
  
=== Proper Linux Kernel Coding Style ===
+
== Proper Linux Kernel Coding Style ==
  
 
Rob Landley writes:
 
Rob Landley writes:
Line 17: Line 17:
 
with any optimizer worth its salt.  Borland C for DOS managed simple dead
 
with any optimizer worth its salt.  Borland C for DOS managed simple dead
 
code elimination 20 years ago...)
 
code elimination 20 years ago...)
 +
 +
[[Category:Development Tools]]

Revision as of 22:11, 30 May 2008

Here are some miscellaneous tips for good code styling:

Proper Linux Kernel Coding Style

Rob Landley writes:

Read: http://www.chris-lott.org/resources/cstyle/ifdefs.pdf

And the section of the old http://www.linuxjournal.com/article/5780 article starting with "No ifdefs in .c Code", about how to move #ifdefs into headers so the functions aren't littered with them. Just a thought...

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...)