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

Rule:  6.7.3.a

Synopsis:"const" shall be used to specify that a variable is non-modifiable.
Language:C
Severity Level:5
Category:Declarations


Description:

Justification

It is a good programming practice to specify at declaration and definition of variables or parameters that their values will not be changed or, in case of a pointer, that their reference will not be changed.

Example

int get_status(DATE_STRUCT *sh_data) /* WRONG, sh_data is an input param */
/**
 * \brief Returns the time to the next maintenance action
 * \param[in] sh_data The shared data structure
 …
 */
{
  return sh_data->val;
}

int get_status(const DATE_STRUCT *sh_data) /* RIGHT */
/**
 * \brief Returns the time to the next maintenance action
 * \param[in] sh_data The shared data structure
 …
 */
{
  return sh_data->val;
}