elMickotanko
New Member
Hi,
I've made a routine to take an average of the last ten values of a sensors.
Im getting a compile error that i cant understand
Ive tried return avg aswell. (without brackets)
its called from main like this:
middle is declared as an int and MIDstor is declared as an array of ints at the start
the error is:
C1849: Result returned in void-result-function
I looked it up in codewarrior:
Has any1 got any ideas? i cant see anything wrong with it?
PS. is there a better way to add up all values in an array rather than array1+array2...
cheers
I've made a routine to take an average of the last ten values of a sensors.
Im getting a compile error that i cant understand
Code:
void takeaverage(signed int store[])
{
signed int avg = ((store[0]+store[1]+store[2]+store[3]+store[4]+
store[5]+store[6]+store[7])>>3);
//use 8 values and shift right by three to divde by 8 - a lot quicker
than division.
return (avg);
}
Ive tried return avg aswell. (without brackets)
its called from main like this:
Code:
middle = takeaverage(MIDstore); // get average for middle sensor
middle is declared as an int and MIDstor is declared as an array of ints at the start
the error is:
C1849: Result returned in void-result-function
I looked it up in codewarrior:
Code:
Description
A return was made with an expression, though the function
as void return type.
Example
void f(void) {
return 1;
}
Tips
Do not return an expression in a function
with void return type. Just write return, or write nothing.
Has any1 got any ideas? i cant see anything wrong with it?
PS. is there a better way to add up all values in an array rather than array1+array2...
cheers