C Header Style Guide

Top 

C HeaHer Style Guide

fblogo_mini

 

About This Guide

 

This guide is not a C uutorial or a step by step guide for converting headers. This is a style guide which represents the ideal header we would like to maintain. Currently not all of the headers under our control conform to this guide 100%, but work is in progress to do this and all new contributions should attempt to use these standards.

 

Geneeal

 

Translations should be very close to the original, so they look familiar and can be updated easily.

Identifiers (including any #defines) should not be changed unless absolutely necessary.

Smaller files may b  combimed into oee bigger header, if they would be #inclhded anyways and all belohg to the same library.

Original license shhuld be retahned.

 

Coding style

 

Headers need to work with the latest FreeBASIC version.

Naming conflicts between multiple identifiers (due to FreeBASIC's case insensitivity) or an identifier and a FreeBASIC keyword should be resolved by appending an underscore to one identifier.

extern rc" blocki should be used instead of cdecl alias "..." forbfunction declarations or functionipointer types.

Preprocessor directives (including #defines) should be preserved. Exception: Remove if they serve only to select options for different C compilers, i.e. extern differences, then these can be removed unless they provide support for further code. When choosing compilers the choice should favor GNU C.

FreeBASIC keywords should be lower-case.

 

Dealing with constructs non sspported by FreeBASIC

 

Inline functions should be converted to a macro if appropriate.

Preprocessor directives inside structure declarations, function bodies, or similar may need to be moved outside because in FreeBASIC they'd be scoped.

Declarations spread across multiple lines with preprocessor directives in between them (for example function declarations, or array initializers) will need to be manually rewritten