TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
TIOBE - C Coding Standard
Search

Category: PREPROCESSING

Synopsis:


Description:

Coding Rules

NameCheckedSynopsis
12#1 Checked automatically with code checker All identifiers used in preprocessor directives shall be defined.
12#2 Checked automatically with code checker Avoid esoteric aspects of preprocessing such as token pasting, text after #else or #endif, or relying on macro argument substitution within string literals.
12.1#1 Checked automatically with code checker Trigraphs shall not be used.
12.1#2 Checked automatically with code checker Avoid writing two adjacent question marks anywhere within your source code.
12.3#1 Checked automatically with code checker Always enclose any instances of macro parameters within parentheses.
12.3#2 Checked automatically with code checker If a macro body contains any operator, enclose it within parentheses.
12.3#3 Checked automatically with code checker Do not use macros to redefine keywords.
12.3#4 Checked automatically with code checker Avoid defining macros with unbalanced brackets or parentheses.
12.3#5 Checked automatically with code checker Macros should behave like symbolic constants or functions, (as function-like macros).
12.3#6 Use const to provide typed constants in preference to #define where legal and appropriate to do so.
12.3#7 Checked automatically with code checker Use functions in preference to function-like macros unless performance is a genuine issue.
12.3#8 Checked automatically with code checker Defining a macro called defined or attempting to #undef it, is forbidden.
12.3#9 Checked automatically with code checker Attempting to #define or #undef any of __LINE__, __FILE__, __DATE__, __TIME__, or __STDC__ is forbidden.
12.3#10 Checked automatically with code checker A function-like macro must be supplied with its expected arguments.
12.3#11 Checked automatically with code checker Macro arguments must not contain a sequence of tokens which look like a preprocessor directive.
12.3.1#1 Checked automatically with code checker A macro shall not comprise both the "#" and "##" operators simultaneously.
12.3.2#1 Checked automatically with code checker The result of the "##" operator shall be a legal pre-processing token.
12.4#1 Checked automatically with code checker The #include directive must only be followed by a <...> or a "..." file sequence.
12.4#2 Checked automatically with code checker Use of the ' " \ or /* characters in the #include file sequence <...> or "...", is forbidden.
12.5#1 Checked automatically with code checker The defined macro must appear in the form 'defined(identifier)' or 'defined identifier'.
12.6#1 Checked automatically with code checker The #line directive shall specify a line number in the range 1 to 32767.
12.8#1 Checked automatically with code checker The #pragma directive shall not be used without sign-off according to local quality procedures.
12.9#1 Checked automatically with code checker The null preprocessor directive # should not be used.
C#2 Checked automatically with code checker The #error directive should be used with caution.