The C Programming Style that I Follow

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.

Eric Zhiqiang Ma

Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *