> Thanks for the answer > > If i insert the "return" between braces, like > > > static READ32_HANDLER( port1_r ) > { > UINT16 viewval = readinputport(1); > UINT16 viewdiff = viewval ^ last_port1; > if ((viewdiff & 0x0010) && !(viewval & 0x0010)) > { > if (view_state==0) {view_state = 4;} //1st view > else if (view_state==4) {view_state = 2;} //2nd view > else if (view_state==2) {view_state = 1;} //3rd view > else if (view_state==1) {view_state = 4;} //1st view > last_port1 = viewval; > viewval = (viewval | 0x00f0) ^ (view_state << 4); > return (viewval << 16) | viewval; > } > } > > While compiling it reports an error to the last line (that with the closing brace): > "control reaches end of non-void function" > > How should i write it? Maybe it needs something to be returned before closing ? > > Thanks a lot
"non-void function" means "function that must always return a value" With your modification port1_r returns a value only when the button is pressed (released), so the compiler gives you that error READ32_HANDLER generates a function that must return a 32 bit number (as the term "read handler" suggests)