Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

The GNU C Programming Tutorial - Style

Node:Style, Next:, Previous:Recursion, Up:Top



Style

C has no rules about when to start new lines, where to place whitespace, and so on. Users are free to choose a style which best suits them, but unless a strict style is adopted, sloppy programs tend to result.

In older compilers, memory restrictions sometimes necessitated bizarre, cryptic styles in the interest of efficiency. However, contemporary compilers such as GCC have no such restrictions, and have optimizers that can produce faster code than most programmers could write themselves by hand, so there are no excuses not to write programs as clearly as possible.

No simple set of rules will ever provide a complete methodology for writing good programs. In the end, experience and good judgment are the factors which determine whether you will write good programs. Nevertheless, a few guidelines to good style can be stated.

Many of the guidelines in this chapter are the distilled wisdom of countless C programmers over the decades that C has existed, and some come directly from the GNU Coding Standards. That document contains more good advice than can be crammed into this short chapter, so if you plan to write programs for the Free Software Foundation, you are urged to consult Table of Contents.

 
 
  Published under free license. Design by Interspire