I have this function:
void InitS(unsigned int &numS){
// this function returns a container for unsigned int
// but it has a cast for int
numS = props.numOfS();
if (numS > 0) {
..
}
}
It compiles but gives me this MISRA warning:
MISRA-C++ Rule 4-10-2 (required): Literal zero (0) shall not be used as the null-pointer-constant.
Now, if numShots
were a "real" pointer I could have changed 0
to NULL
. But numShots
is reference and I should treat it as it was an int
.
What does MISRA want and why?