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

Coding Rules

Rule Kind
Checked automatically with code checker
Severity Level


NameCheckedSynopsis
5.1.1.b Checked automatically with code checker Each source file shall start with a file header, for which the "file name", "description" and copyright notice are to be filled in.
5.1.1.c With respect to includes, each source file (.c and .h) shall be self-contained.
5.1.1.d Only files that are really needed shall be included.
5.1.1.f Checked automatically with code checker With respect to user files, it is good practice to place the include of the header file with the own definitions of the source file at the top.
5.1.1.1.b Checked automatically with code checker The content (body) of every header file shall be enclosed in #ifndef/#if !defined, #define and #endif.
5.1.1.1.c Checked automatically with code checker Naming convention of the include guard of an include file named CCBB_foo.h is of format: CCBB_FOO_H
5.1.1.2.b Checked automatically with code checker Each non-trivial function shall be accompanied by a doxygen style function header.
5.1.2.b Local variables shall not cause stack overflow.
5.1.2.3.a Checked automatically with code checker Side effects shall not be relied upon between successive sequence points.
5.1.2.3.b Checked automatically with code checker Expressions which mix operators from the set ">", ">=", "<", "<=", "==", "!=" with the binary operators from the set "<<", ">>", "^", "&", "|", "&&", "||" and which use two or more distinct operators from the latter set shall be fully parenthesized and shall not depend on the C precedence rules.
5.2.1.1.b Checked automatically with code checker Digraphs shall not be used: "<:", ":>", "<%", "%>", "%:".
5.2.5.a Static dependencies between components shall only be used according to the defined architectural "scope control" rules.
6.2.2.b Checked automatically with code checker Objects and functions with external linkage shall be declared in header files and defined after including the header file that declares them.
6.2.2.c Checked automatically with code checker A variable declaration with storage class static shall have a scope limited to the source file.
6.2.3.a Checked automatically with code checker To avoid name collision, one shall not use the same name for different identifiers.
6.2.4.b Checked automatically with code checker Memory operations shall be symmetric; allocation and de-allocation shall take place in the same scope where the allocated variable is defined.
6.2.5.a Checked automatically with code checker One must not rely on the actual numerical value of an enum variable.
6.3.a Checked automatically with code checker Unsafe implicit conversions in expressions, return statements, assignment statements or argument lists shall not be used. Unsafe means: conversions where values are truncated and/or sign can be lost.
6.3.b Checked automatically with code checker Unsafe implicit conversions of literals shall be avoided.
6.3.1.a Checked automatically with code checker Mixed signed/unsigned type arithmetic shall not be used.
6.3.2.1.a Checked automatically with code checker void expressions shall not be used in expressions.
6.3.2.2.a Checked automatically with code checker Pointer to and from integer conversions shall not be used. For instance on 64-bit x86 processors the size of an integer is 32-bits while the pointer is 64-bits. Therefore converting a pointer to an integer will discard part of the address.
6.3.2.2.b Checked automatically with code checker For generic pointers void * shall be used rather than char *.
6.3.2.2.c Checked automatically with code checker Pointers shall not be converted to other pointer types.
6.3.2.2.d Checked automatically with code checker Pointers shall not be added, multiplied nor divided.
6.3.2.2.e Checked automatically with code checker Pointers shall not be subtracted from each other, unless their unqualified type is the same.
6.3.2.3.a Checked automatically with code checker bool shall be used as boolean type.
6.3.2.3.d Checked automatically with code checker Avoid conversions between booleans and non-boolean types
6.4.b Checked automatically with code checker The tab character (0x09 ASCII) shall not be used.
6.4.1.a Checked automatically with code checker C keywords are reserved for use as keywords and shall not be used otherwise.
6.4.1.b Checked automatically with code checker Only with a very good reason, the asm keyword may be used to insert assembly language directly into the translator output.
6.4.1.1.a Checked automatically with code checker Do not use C++ keywords.
6.4.1.1.b Checked automatically with code checker Do not use C++ alternative representations that are not part of the C keywords (see also 6.4.1.a).
6.4.2.a Checked automatically with code checker Identifiers shall satisfy the standard C syntax for identifiers.
6.4.2.b Checked automatically with code checker Identifiers shall not be defined with one or more leading underscores (_).
6.4.2.d Checked automatically with code checker Don't use extern variable declarations in header files, except for consts.
6.4.4.b Checked automatically with code checker Use suffix 'L' instead of 'l' to avoid confusion
6.4.4.1.a Checked automatically with code checker Only decimal or hexadecimal notation may be used for integer constants.
6.4.4.1.b Checked automatically with code checker Use clear constant values. Small letters shall not be used, expecially to avoid confusion between l (letter l) and 1 (digit one). The letter U shall be written in uppercase to be consistent with the case of the letter L.
6.4.4.3.a Checked automatically with code checker Only the first entry in an enumerator shall be explicitly defined using '='.
6.4.4.4.a Checked automatically with code checker Only ANSI defined escape sequences shall be used.
6.4.5.a Checked automatically with code checker A character string literal token shall not be adjacent to a wide string literal token.
6.4.9.a Checked automatically with code checker Comments in the form of opening (/*) and closing (*/) shall not be nested.
6.4.9.c Checked automatically with code checker Do not use mixed comments.
6.5.a Checked automatically with code checker Bitwise operations shall only be applied on operands of unsigned type.
6.5.2.1.a Checked automatically with code checker Array subscripting requires a pointer to object type and one or more integral subscript expressions. The indices must be within the bounds values of the (allocated) array.
6.5.2.1.b typedef for an array of unknown size shall not be used.
6.5.2.2.b Checked automatically with code checker Do not declare functions within functions.
6.5.2.2.c Checked automatically with code checker Do not use functions marked as deprecated.
6.5.2.3.a Checked automatically with code checker When structures are accessed by means of a pointer, the pointer-to notation -> rather than the member notation * shall be used to denote a specified member of the structure.
6.5.2.3.b Checked automatically with code checker Structs or unions must be passed by reference into functions with variable numbers of parameters.
6.5.2.3.d Checked automatically with code checker Do not use nested structures.
6.5.3.1.a Checked automatically with code checker Do not mix postfix and prefix increment and/or decrement in a statement.
6.5.3.2.a Checked automatically with code checker A variable declared as an array shall not be used as a pointer.
6.5.3.3.a Checked automatically with code checker The unary plus operator shall not be used.
6.5.3.3.b Checked automatically with code checker Unary minus shall only be applied to an operand having a signed arithmetic type.
6.5.3.4.a Checked automatically with code checker sizeof shall not be applied to an expression with side-effects.
6.5.3.4.b Checked automatically with code checker Don't use sizeof on a variable of an array type that is passed as argument.
6.5.4.a Checked automatically with code checker Casting shall only be used to denote required casting.
6.5.7.b Checked automatically with code checker The right operand of a left shift operator for a signed type as left operand shall not be so large that the resulting value cannot be represented.
6.5.8.a Checked automatically with code checker Comparison of unsigned operands shall not occur against negative values.
6.5.8.c Checked automatically with code checker Don't compare floats of different types.
6.5.8.d Comparison of floating point numbers (float or double) shall preferably be avoided.
6.5.8.e Use memcmp only to compare arrays of scalar types.
6.5.8.f Checked automatically with code checker Do not compare floating point numbers with memcmp.
6.5.9.a Checked automatically with code checker Pointer comparison shall only be done for compatible pointer types.
6.5.9.b Checked automatically with code checker Floating point expressions shall not be compared using the "==", "!=" operators. Floating point expressions shall be compared using special functions.
6.5.13.a The right-hand operand of the "&&" or "||" operator shall not contain any side-effects.
6.5.15.a Checked automatically with code checker The second and third operand of a conditional expression of the conditional operator shall not contain side-effects.
6.5.16.a Checked automatically with code checker Do not use nested assignments.
6.5.16.b Checked automatically with code checker Do not discard const qualifiers in pointer assignments.
6.5.17.a Checked automatically with code checker The comma operator shall not be used.
6.7.a Checked automatically with code checker Only one identifier type shall be declared on each source line.
6.7.1.a Checked automatically with code checker Identifiers with file scope shall be declared static, thus preventing them from having global scope.
6.7.1.b Checked automatically with code checker Since auto is redundant it shall be omitted to avoid cluttering up declarations.
6.7.1.c Checked automatically with code checker Since "register" is redundant it shall be omitted to avoid cluttering up declarations.
6.7.2.a Checked automatically with code checker Compiler-specific extensions shall not be used in type specifiers.
6.7.2.b Checked automatically with code checker Every identifier declaration shall include a type specifier.
6.7.2.1.a Checked automatically with code checker Do not use bit-fields for combining multiple logical values in one memory location.
6.7.2.2.a Checked automatically with code checker Mixing of different enum types is not allowed.
6.7.3.a "const" shall be used to specify that a variable is non-modifiable.
6.7.5.a Checked automatically with code checker Only variables and parameters that are used shall be declared.
6.7.5.2.a Checked automatically with code checker Array bounds shall be specified as integral constant expressions.
6.7.5.3.a All function prototypes shall specify the type and the name of each of their parameters.
6.7.5.3.b Checked automatically with code checker A function shall only be used if its prototype is known.
6.7.8.a Checked automatically with code checker All variables shall be initialized or assigned before being read.
6.7.8.b Checked automatically with code checker The initializer for a struct, union or array shall be enclosed in braces.
6.7.8.c Checked automatically with code checker For a struct the initializer should be {0} or all fields should be initialized.
6.7.8.d Checked automatically with code checker All variables containing a pointer shall be initialized.
6.8.a Checked automatically with code checker All control statements shall be fully brace enclosed. This means that all "if", "while", "for", "do" and "switch" statements are followed by a brace-enclosed compound statement.
6.8.c Checked automatically with code checker Any statement that is logically never executed shall not occur in the source code.
6.8.d Checked automatically with code checker Avoid magic numbers.
6.8.1.a Checked automatically with code checker Statements shall not be labelled except for "case" and "default" in a switch-statement.
6.8.3.a Checked automatically with code checker Each expression and statement shall have an effect.
6.8.3.b Checked automatically with code checker A null statement (;) shall not be used.
6.8.4.b Checked automatically with code checker The condition (or guard) of a selective alternative shall be a logical operator, an equality operator or a relational expression (and not be an assignment). Exception is made for boolean type. For boolean type no relational expression is required.
6.8.4.c The termination condition of iterations shall be of type boolean.
6.8.4.1.b Checked automatically with code checker N-ary selection constructs programmed using "if ... else if ..." shall have an "else" clause.
6.8.4.2.a Checked automatically with code checker The switch expression shall not contain any logical expression (one or more of the ">", ">=", "<", "<=", "==", "!=", "&&", "||" or "!" operators).
6.8.4.2.b Checked automatically with code checker "switch" statements shall have one and only one "default" clause.
6.8.4.2.c Checked automatically with code checker Each non empty case clause and default clause shall end with a break statement.
6.8.4.2.d Checked automatically with code checker The default clause shall be the last entry in the switch statement.
6.8.4.2.e Checked automatically with code checker Make sure all code in a switch statement serves a purpose.
6.8.5.a Checked automatically with code checker The termination condition of iteration shall not have a constant value.
6.8.5.1.a Checked automatically with code checker The variables used in expression 2 of a "for" loop shall not be changed in the loop body and expression 3 at the same time.
6.8.5.1.c Checked automatically with code checker The loop variable of a for loop shall be used in the loop body.
6.8.6.1.a Checked automatically with code checker The "goto" statement shall not be used.
6.8.6.2.a Checked automatically with code checker The "continue" statement shall not be used.
6.8.6.3.a Checked automatically with code checker The break statement shall not be used to exit from an iteration statement ("for" or "while").
6.8.6.4.a Checked automatically with code checker There shall be exactly one "return" statement in a function returning non-void.
6.8.6.4.b Checked automatically with code checker There shall be no return statement in a void function.
6.8.6.4.c Checked automatically with code checker A function "return" expression shall be compatible with its explicitly defined type.
6.8.6.4.d Checked automatically with code checker Function return values that are error codes shall not be ignored.
6.9.1.a Checked automatically with code checker Function pointer parameters should not be declared as ordinary pointer type. A type should be used which is declared by a "typedef" declaration.
6.9.1.b Checked automatically with code checker Do not use K&R declaration style.
6.9.2.a Checked automatically with code checker Explicitly use "static" or "extern" on all global const declarations.
6.9.2.b Only static global variables that are used shall be declared.
6.10.a Checked automatically with code checker Use of pre-processor directives shall be according to strict ANSI syntax and constraints.
6.10.b Checked automatically with code checker Only perform token pasting with the token pasting operator (##).
6.10.1.a Checked automatically with code checker Code checker flags shall not be used in the source code.
6.10.1.c Checked automatically with code checker #ifdef, #ifndef, #if defined and #if !defined are not allowed in external header files.
6.10.1.d Checked automatically with code checker C headers should be guarded by extern "C".
6.10.2.a Checked automatically with code checker All headers files shall be identified by an #include directive.
6.10.2.b Checked automatically with code checker Including source files is not allowed.
6.10.2.c Checked automatically with code checker It is forbidden to include hpp files in C files.
6.10.3.a Use of macros shall strictly be according to the ANSI C89 macro syntax and within the ANSI C89 macro constraints.
6.10.3.b Checked automatically with code checker #define macros shall only be used for symbolic constants. They shall not be used for function like macros if a function can be written to accomplish the same task.
6.10.3.c Checked automatically with code checker Any instance of macro parameters, macro body and macro operations shall be enclosed within parenthesis.
6.10.3.d Checked automatically with code checker Macros should not end with a semicolon.
6.10.3.e Checked automatically with code checker Use a semicolon at the end of a function-like macro call.
6.10.3.2.b Checked automatically with code checker A macro shall not comprise both the "#" and "##" operators simultaneously.
6.10.3.3.a Checked automatically with code checker Result of "##" operator shall be a legal pre-processing token.
6.10.3.4.a Checked automatically with code checker Recursive macro definitions shall not be used.
6.10.3.5.a Checked automatically with code checker Macros shall only be #define'd and #undef'ed at file scope.
6.10.4.a Checked automatically with code checker The line splicing character ('\' at the end of a line) shall not be used, except in preprocessor macros.
6.10.4.b Checked automatically with code checker When used, the line-splicing character ('\' at the end of a line) shall immediately be followed by the newline character.
6.10.4.c Checked automatically with code checker Do not use mixed EOL characters in a file.
6.10.6.a Checked automatically with code checker The pragma directive and pragma operator shall not be used.
6.10.8.b Checked automatically with code checker Only the predefined macro names __FILE__, __LINE__ and __func__ may be used.
7.2.a Checked automatically with code checker The standard header file assert.h shall not be used.
7.12.a Checked automatically with code checker The arguments to any mathematical function shall be within the appropriate range.
7.12.b Any calculation result shall not overflow the corresponding output parameter or return value data type.
7.13.a Checked automatically with code checker The setjmp() function and its counterpart longjmp() shall not be used.
7.18.a Checked automatically with code checker Do not define types or macros with the same name as types or macros in stdint.h.
7.19.a Checked automatically with code checker Only standard output specifiers and standard flags shall be used in output format specifications.
7.19.b Checked automatically with code checker The arguments in a formatted output function shall match the output specifiers in the format specification.
7.19.c Checked automatically with code checker Only standard input specifiers and standard flags shall be used in input format specifications.
7.19.d Checked automatically with code checker The arguments in a formatted input function shall match the input specifiers in the format specification.
7.19.e The number of arguments to printf formats should correspond to the actual arguments.
7.19.f Checked automatically with code checker Do not access members of type FILE directly.
7.19.g Checked automatically with code checker Do not use the same buffer for reading and writing when calling input/output functions.
7.21.a Checked automatically with code checker Don't use the functions strerror and strtok, instead use their re-entrant counterparts strerror_r and strtok_r.
7.23.a Checked automatically with code checker Don't use the functions asctime, ctime and gmtime instead use their re-entrant counterparts asctime_r, ctime_r and gmtime_r.
7.26.1.a Checked automatically with code checker Don't use the functions readdir instead use the re-entrant counterpart readdir_r
7.26.2.a Checked automatically with code checker Don't use the functions rand. Instead use the re-entrant counterpart rand_r.