Home » programming

The C Programming Style that I Follow

By: Zhiqiang Ma On: Mar 5, 2010 Views: 22 No Comment Print Email
Tags: , ,

C programming language allow any style the programmer like. A good style can make the code easy to understand and maintain, while a bad style will make the project a nightmare.

This is the C programming styles that I follows:

1. For each source file (*.c), there is a header file (*.h) that have the same name with it as it’s interface.

2. The header file starts with

#ifndef _HEADER_NAME_H
#  define  _HEADER_NAME_H

And end with:

#endif // _HEADER_NAME_H

3. #include is only used in source file usually. ONLY when it is really necessary, #include can be used in header file.

4. There is NO definition in header file.

5. Global variable defined in source file that is visible outside the module is declared as extern variable in the relevant header file. Global variable is used only when it is really necessary.

An example that follow this style is mrcc.

Read more:

Digg del.icio.us Stumble Techorati Facebook Newsvine Reddit Twitter
Mixx LinkedIn Google Bookmark Yahoo Bookmark MySpace LiveJournal Blogger RSS feed
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.