C Coding Standard Recommendations

This is a preliminary attempt to come up with a set of C coding recommendations for Upgrade Silicon Software developers. A meeting was held on 20 April 1995 to come up with a set of standards. This is just a compilation of all the recommendations. It should be noted that not all of the recommendations are meant to be strictly followed. (Any statement with MUST is to be strictly followed. Anything with SHOULD is strongly recommended)

Header Files

Every Header file must include:

     #ifndef <FILENAME_H>
     #define <FILENAME_H>
     .
     .
     .
     #endif

at the start with a name which corresponds to filename.h. For example, if you have a file called types.h, the first two lines in that file ignoring comments must be:


     #ifndef TYPES_H
     #define TYPES_H
     .
     .
     .
     #endif


Declarations

The "pointer" qualifier, '*', must be with the variable name rather than with the type.
char *s, *t, *u;
instead of
char* s, t, u;
as C compilers may handle these assignments differently.

Functions


Code Formatting


Macros

Refrain from using macros except when absolutely necessary. If used, the name of the macro must clearly describe what it does. This will save a great deal of time in searching through code to find what the macro does.
Send any comments or suggestions to
lpaterno@d0sf26.fnal.gov

Last Updated : 19-March-1996