CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Warning 208 Function not void and does not return a value

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Will Reeve
Guest







Warning 208 Function not void and does not return a value
PostPosted: Thu Jun 19, 2003 3:21 am     Reply with quote

I get a few of these…is it my writing style as I can’t see what’s wrong with the function:

/**************************************************************
* acc(signed int16 *a)
* Purpose: Procedure called to perform dual scale acceleration function on
* digipot counters.
*/
void acc(signed int16 *a) {
if (*a>4 | *a<4) *a*=4; else
if (*a>2 | *a<2) *a*=2;
} // void acc(signed int16 *a)

It works OK, just generates a warning,

Will
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515377
Daniel Brännwik
Guest







Re: Warning 208 Function not void and does not return a valu
PostPosted: Thu Jun 19, 2003 3:52 am     Reply with quote

:=
:=
:=I get a few of these…is it my writing style as I can’t see what’s wrong with the function:
:=
:=/**************************************************************
:=* acc(signed int16 *a)
:=* Purpose: Procedure called to perform dual scale acceleration function on
:=* digipot counters.
:=*/
:=void acc(signed int16 *a) {
:= if (*a>4 | *a<4) *a*=4; else
:= if (*a>2 | *a<2) *a*=2;
:=} // void acc(signed int16 *a)
:=
:=It works OK, just generates a warning,
:=
:=Will

Maybe I am missing something but I think you really have something like this in mind:
if (*a>4 || *a<4) *a*=4; else
if (*a>2 || *a<2) *a*=2;

Assuming I understand your intention correctly, wouldn't "if (a!=4) *a*=4; else *a*=2;" do the same thing?

Best regards
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515378
Dave Yeatman
Guest







Re: Warning 208 Function not void and does not return a valu
PostPosted: Thu Jun 19, 2003 6:33 am     Reply with quote

Is the function below the exact wording of the one giving you the warning??

The few times I have seen this I had neglected to put the word VOID in front of the function name so the system expected I would be returning a value(which I wasn't). It shouldn't mean there is anything wrong with the function. This is just a gentle nudge from the compiler that, if you wanted to return a value, you didn't. :-)

You can suppress these so they won't show up if you choose.

Dave
:=
:=
:=I get a few of these…is it my writing style as I can’t see what’s wrong with the function:
:=
:=/**************************************************************
:=* acc(signed int16 *a)
:=* Purpose: Procedure called to perform dual scale acceleration function on
:=* digipot counters.
:=*/
:=void acc(signed int16 *a) {
:= if (*a>4 | *a<4) *a*=4; else
:= if (*a>2 | *a<2) *a*=2;
:=} // void acc(signed int16 *a)
:=
:=It works OK, just generates a warning,
:=
:=Will
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515381
Will Reeve
Guest







Re: Warning 208 Function not void and does not return a valu
PostPosted: Thu Jun 19, 2003 6:45 am     Reply with quote

What it does is perform “acceleration” on a value of digipot (rotational encoder) clicks that are measured on a timer interrupt (i.e. clicks per unit time). So if after a set time the digipot has been clicked 4+ times then you want to accelerate the movement, if it’s 2+ times then you want to accelerate it a little less, if less than 2 then you want the precision and only want the exact number of clicks.

I think your suggestion would loose the part when the number of clicks is <2 don’t accelerate at all?
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515383
Will Reeve
Guest







Re: Warning 208 Function not void and does not return a valu
PostPosted: Thu Jun 19, 2003 6:48 am     Reply with quote

That’s exactly cut and pasted out of the code. I get this warning on a couple of other functions as well (one an interrupt function that I don’t pass any variable in or out of!). Strange.
I’ve only just recompiled it with the new “warnings enabled” compiler so before never noticed anything wrong with it.
:=Is the function below the exact wording of the one giving you the warning??
:=
:=The few times I have seen this I had neglected to put the word VOID in front of the function name so the system expected I would be returning a value(which I wasn't). It shouldn't mean there is anything wrong with the function. This is just a gentle nudge from the compiler that, if you wanted to return a value, you didn't. :-)
:=
:= You can suppress these so they won't show up if you choose.
:=
:=Dave
:=:=
:=:=
:=:=I get a few of these…is it my writing style as I can’t see what’s wrong with the function:
:=:=
:=:=/**************************************************************
:=:=* acc(signed int16 *a)
:=:=* Purpose: Procedure called to perform dual scale acceleration function on
:=:=* digipot counters.
:=:=*/
:=:=void acc(signed int16 *a) {
:=:= if (*a>4 | *a<4) *a*=4; else
:=:= if (*a>2 | *a<2) *a*=2;
:=:=} // void acc(signed int16 *a)
:=:=
:=:=It works OK, just generates a warning,
:=:=
:=:=Will
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515384
Dave Yeatman
Guest







Re: Warning 208 Function not void and does not return a valu
PostPosted: Thu Jun 19, 2003 7:05 am     Reply with quote

In which case it looks to me like a compiler error and I would send the code to CCS so they can find out why...

Dave

:=That’s exactly cut and pasted out of the code. I get this warning on a couple of other functions as well (one an interrupt function that I don’t pass any variable in or out of!). Strange.
:=I’ve only just recompiled it with the new “warnings enabled” compiler so before never noticed anything wrong with it.
:=:=Is the function below the exact wording of the one giving you the warning??
:=:=
:=:=The few times I have seen this I had neglected to put the word VOID in front of the function name so the system expected I would be returning a value(which I wasn't). It shouldn't mean there is anything wrong with the function. This is just a gentle nudge from the compiler that, if you wanted to return a value, you didn't. :-)
:=:=
:=:= You can suppress these so they won't show up if you choose.
:=:=
:=:=Dave
:=:=:=
:=:=:=
:=:=:=I get a few of these…is it my writing style as I can’t see what’s wrong with the function:
:=:=:=
:=:=:=/**************************************************************
:=:=:=* acc(signed int16 *a)
:=:=:=* Purpose: Procedure called to perform dual scale acceleration function on
:=:=:=* digipot counters.
:=:=:=*/
:=:=:=void acc(signed int16 *a) {
:=:=:= if (*a>4 | *a<4) *a*=4; else
:=:=:= if (*a>2 | *a<2) *a*=2;
:=:=:=} // void acc(signed int16 *a)
:=:=:=
:=:=:=It works OK, just generates a warning,
:=:=:=
:=:=:=Will
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515387
R.J.Hamlett
Guest







Re: Warning 208 Function not void and does not return a valu
PostPosted: Thu Jun 19, 2003 9:00 am     Reply with quote

:=What it does is perform “acceleration” on a value of digipot (rotational encoder) clicks that are measured on a timer interrupt (i.e. clicks per unit time). So if after a set time the digipot has been clicked 4+ times then you want to accelerate the movement, if it’s 2+ times then you want to accelerate it a little less, if less than 2 then you want the precision and only want the exact number of clicks.
:=
:=I think your suggestion would loose the part when the number of clicks is <2 don’t accelerate at all?
I think the 'key', is that the double test criteria do seem unnecessary. Your first test, just tests for (*a !=4), and the second, for (*a !=2). In both cases the single test might well be quicker, especially when dealing with pointers (which take a significant time to decode). In the first case particularly, you are testing for a not equal condition, and then have both conditions used. There is also the extra time overhead involved in doing a bitwise 'or', rather than a logical 'or' (generally the latter only involved testing for the non-zero status bit).
As written, the second line, can only be reached if *a==4. Given this, the next test, is wasted (since it is allways going to be true...
As written, your tests do not evaluate as you think they do. I think the second test in each line, is meant to be against -4, and -2 respectively, not 4 and 2 as written.

I'd expect the code might be a fraction faster, written as:

int16 temp;
temp=abs(*a);
if (temp>4) *a *=4;
else if (temp>2) *a *=2;

Generally, the compiler is faster dealing with numbers accessed directly, than with values through pointers, so it'd probably be faster still to have the function return a value, and not use the pointers at all!.

So:
signed int16 acc(signed int16 a) {
int16 temp;
temp=abs(a)
if (temp>4) return(a*4); else
if (temp>2) return(a*2);
return(a);
}

On your original question, the possibility arises that the fault is actually in the function 'in front'. It is fairly common for the CCS compiler to report a problem with the next function, when the error is earlier in the code...

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515394
Will Reeve
Guest







Re: Warning 208 Function not void and does not return a valu
PostPosted: Thu Jun 19, 2003 9:44 am     Reply with quote

Thank you!!!!! What I really wanted is as you guessed:

void acc(signed int16 *a) {
if (*a>4 | *a<-4) *a*=4; else
if (*a>2 | *a<-2) *a*=2;
} // void acc(signed int16 *a)

I coded it wrong! The variable which gets sent in is +ve for clockwise clicks and –ve for anti-clockwise clicks…my acceleration would only work for clockwise twisting…how easily these things get through my brain but not to my fingers…I knew what I wanted to do and thought I had coded it to do it!

I owe you a big thanks for pointing this out!

Will
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515396
R.J.Hamlett
Guest







Re: Warning 208 Function not void and does not return a valu
PostPosted: Thu Jun 19, 2003 10:58 am     Reply with quote

:=Thank you!!!!! What I really wanted is as you guessed:
:=
:=void acc(signed int16 *a) {
:=if (*a>4 | *a<-4) *a*=4; else
:=if (*a>2 | *a<-2) *a*=2;
:=} // void acc(signed int16 *a)
:=
:=I coded it wrong! The variable which gets sent in is +ve for clockwise clicks and –ve for anti-clockwise clicks…my acceleration would only work for clockwise twisting…how easily these things get through my brain but not to my fingers…I knew what I wanted to do and thought I had coded it to do it!
:=
:=I owe you a big thanks for pointing this out!
:=
:=Will
Quite nice, trying to crack the '208' warning, and instead get the code working right. :-)
Now all that is needed is to find what is causing the original error!...
Hope your find this as well (I would look very carefully 'in front', this type of message, seems to pop up allmost 'at random', for errors often many dozens of lines earlier).

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515399
Will Reeve
Guest







Re: Warning 208 Function not void and does not return a valu
PostPosted: Thu Jun 19, 2003 2:18 pm     Reply with quote

<font face="Courier New" size=-1>The scary thing is; that code has been beta-testing for the last month in the hardware and no one noticed it didn’t work correctly until I just demonstrated it to them!

Anyway, back to the original problem…that warning. You are correct again…the function before was an interrupt function and didn’t have a void in front of it. Stranger still; when I fixed that I got the following warning:

Warning 214: Operator precedence rules may not be as intended, use () to clarify

Guess what lines generated that warning…yes once the code was changed to:

void acc(signed int16 *a) {
if ((*a>4) | (*a<-4)) *a*=4; else
if ((*a>2) | (*a<-2)) *a*=2;
} // void acc(signed int16 *a)

I get a warning free complication.

Result in more ways than one! I guess the CCS guys have some fine-tuning to do with the warning feature!

Thanks, it’s been fun!

Will ___________________________
This message was ported from CCS's old forum
Original Post ID: 144515403
R.J.Hamlett
Guest







Re: Warning 208 Function not void and does not return a valu
PostPosted: Thu Jun 19, 2003 2:29 pm     Reply with quote

:=<font face="Courier New" size=-1>The scary thing is; that code has been beta-testing for the last month in the hardware and no one noticed it didn’t work correctly until I just demonstrated it to them!
:=
Oops!...

:=Anyway, back to the original problem…that warning. You are correct again…the function before was an interrupt function and didn’t have a void in front of it. Stranger still; when I fixed that I got the following warning:
:=
:=Warning 214: Operator precedence rules may not be as intended, use () to clarify
:=
Yes. This is generally, well worthwhile in general, and even more so in this C...

:=Guess what lines generated that warning…yes once the code was changed to:
:=
:=void acc(signed int16 *a) {
:= if ((*a>4) | (*a<-4)) *a*=4; else
:= if ((*a>2) | (*a<-2)) *a*=2;
:=} // void acc(signed int16 *a)
:=
:=I get a warning free complication.
:=
:=Result in more ways than one! I guess the CCS guys have some fine-tuning to do with the warning feature!
:=
:=Thanks, it’s been fun!
:=
:=Will
Glad it is all working now.

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515405
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group