View previous topic :: View next topic |
Author |
Message |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
How to get rid of warning when using _return_ feature? |
Posted: Thu Jan 13, 2005 1:53 pm |
|
|
I copied the find_parity() example from the Sept-2004 manual but can't get rid of the warning 'Function not void and does not return a value'.
I'm using PCWH v3.212 for the PIC18F458.
Code: | #include <18F458.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=16000000)
// This routine was copied from the CCS manual.
int find_parity(int data_char)
{
int count;
#asm
movlw 0x8
movwf count
movlw 0
loop:
xorwf data_char,w
rrncf data_char,f // use 'rrf' for pic16
decfsz count,f
goto loop
movwf _return_
#endasm
}
void main()
{
int8 data;
int8 parity;
parity = find_parity(data);
parity = find_parity(data);
} |
The above code is working and I do like the use of _return_, but how to get rid of the warning? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 13, 2005 2:05 pm |
|
|
One way is to add this line to your program:
#ignore_warnings 208 |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Jan 13, 2005 10:26 pm |
|
|
It will cost you a couple of bytes but:
Code: |
#include <18F458.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=16000000)
int8 wreg;
#locate wreg = 0xFE8
// This routine was copied from the CCS manual.
int find_parity(int data_char)
{
int count;
#asm
movlw 0x8
movwf count
movlw 0
loop:
xorwf data_char,w
rrncf data_char,f // use 'rrf' for pic16
decfsz count,f
goto loop
// movwf _return_
#endasm
return wreg;
}
void main()
{
int8 data;
int8 parity;
parity = find_parity(data);
parity = find_parity(data);
}
|
|
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Fri Jan 14, 2005 2:21 am |
|
|
Thanks PCMprogrammer and Mark, both your suggestions will remove the warning message.
I just don't like it that these are workarounds and have side effects. Use of the _return_ feature is documented in the manual so I feel like it shouldn't give a warning message.
For now I'll do with one of the workarounds AND post it to ccssupport. |
|
|
|