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

Rule:  6.5.2.3.bChecked automatically with code checker

Synopsis:Structs or unions must be passed by reference into functions with variable numbers of parameters.
Language:C
Severity Level:5
Category:Expressions


Description:

Justification

The C standard requires that the type of function arguments matches the type of the parameters the function expects. Arguments for functions with variable numbers of parameters cannot be verified at compile time; therefore potential mismatches can only be detected at run time.

Passing a struct or union by value while the function expects a reference (or vice versa) is a common type of programming error. The runtime problem may not even appear with certain compiler- or target settings, making the programming error hardly detectable.

This rule aims to prevent this type of error by limiting the number of ways a struct or union may be passed to functions with variable numbers of parameters.

Example

{
   timestamp time;

   ...

   trace(CC, TRACE_INT, __func__, "time=%T", time); /* WRONG */
   trace(CC, TRACE_INT, __func__, "time=%T", &time); /* RIGHT */
}