I have a variable
uint16_t a=35; and I have a function
UINT Read(unsigned int& nVal);
How do I pass
If I pass like this
I am getting the error below:
cannot convert parameter 1 from 'uint16_t' to 'unsigned int &
You will need to copy the value into a (named) temporary, call the function, and then copy the temp back (possibly after checking for overflow).
uint16_t a = 35; ... unsigned int temp = a; const unsigned int result = Read(temp); // check for overflow here a = temp;
Of course, if you can change the definition of
a to be
unsigned int, then that is much more straightforward (but I assume that is not possible for other reasons).