Hubbry Logo
search
logo

GNU coding standards

logo
Community Hub0 Subscribers

GNU coding standards

logo
Community Hub0 Subscribers
Write something...
Be the first to start a discussion here.
Be the first to start a discussion here.
See all
GNU coding standards

The GNU coding standards are a set of rules and guidelines for writing programs that work consistently within the GNU system. The GNU Coding Standards were written by Richard Stallman and other GNU Project volunteers. The standards document is part of the GNU Project and is available from the GNU website. Though it focuses on writing free software for GNU in C, much of it can be applied more generally. In particular, the GNU Project encourages its contributors to always try to follow the standards—whether or not their programs are implemented in C.

The GNU Coding Standards specify exactly how to format most C programming language constructs. Here is a characteristic example:

The consistent treatment of blocks as statements (for the purpose of indentation) is a very distinctive feature of the GNU C code formatting style; as is the mandatory space before parentheses. All code formatted in the GNU style has the property that each closing brace, bracket or parenthesis appears to the right of its corresponding opening delimiter, or in the same column.

Being tightly integrated with the GNU system, GNU Emacs provides automatic formatting of C code to match the GNU coding standards. Rather than manually modifying code formatting in a way that strays from the GNU coding standards, the formatted layout of the code can be tweaked by writing it in a more Emacs-friendly form—for example, by inserting additional parentheses.

"When you split an expression into multiple lines, split it before an operator, not after one."

For example:

The standards greatly emphasise the importance of English-language comments:

Please write the comments in a GNU program in English, because English is the one language that nearly all programmers in all countries can read. If you do not write English well, please write comments in English as well as you can, then ask other people to help rewrite them. If you can't write comments in English, please find someone to work with you and translate your comments into English.

See all
User Avatar
No comments yet.