View previous topic :: View next topic |
Author |
Message |
object01
Joined: 13 May 2004 Posts: 90 Location: Nashville, TN
|
Warning 202: "Variable never used rs232_errors" |
Posted: Sun Mar 27, 2005 1:55 am |
|
|
Is there a way to ignore this warning? Wrapping my #use rs232 declarations in an #ignore_warnings 202 block doesn't seem to do the trick. I keep "errors" in those declarations because it's my understanding that that causes the compiler to generate error-flag cleanup code, and I'd just as soon keep that. But the warning is just annoying.
--
Jeff S. |
|
|
bluetooth
Joined: 08 Jan 2005 Posts: 74
|
|
Posted: Sun Mar 27, 2005 7:56 am |
|
|
If removing this annoyance is worth one instruction word, add the following early in your program:
This is one of the other ways to make this error go away.... |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
Re: Warning 202: "Variable never used rs232_errors" |
Posted: Sun Mar 27, 2005 8:21 am |
|
|
object01 wrote: | Is there a way to ignore this warning? Wrapping my #use rs232 declarations in an #ignore_warnings 202 block doesn't seem to do the trick. I keep "errors" in those declarations because it's my understanding that that causes the compiler to generate error-flag cleanup code, and I'd just as soon keep that. But the warning is just annoying.
--
Jeff S. |
I believe that you should be using "ERRORS" and not "RS232_ERRORS" according to the manual. |
|
|
bluetooth
Joined: 08 Jan 2005 Posts: 74
|
|
Posted: Sun Mar 27, 2005 8:30 am |
|
|
Mark:
RS232_errors is a variable that holds that USART status.... ERRORS is the directive for the #use RS232 command.... |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Mar 27, 2005 12:20 pm |
|
|
Quote: |
Wrapping my #use rs232 declarations in an #ignore_warnings 202 block
doesn't seem to do the trick. |
Not sure what you mean by a "block". The placement shown below
stops the warnings.
Code: | #include <16F877.h>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#ignore_warnings 202
//--------------------------------------------
void main()
{
while(1);
} |
|
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Sun Mar 27, 2005 4:17 pm |
|
|
bluetooth wrote: | Mark:
RS232_errors is a variable that holds that USART status.... ERRORS is the directive for the #use RS232 command.... |
Yeah I know that, I thought he was using RS232_errors in the #use rs232. I don't use those functions except when helping others out. I don't get the warning either so I figured he must be doing something different. |
|
|
object01
Joined: 13 May 2004 Posts: 90 Location: Nashville, TN
|
|
Posted: Mon Mar 28, 2005 8:26 am |
|
|
PCM programmer wrote: |
Not sure what you mean by a "block". The placement shown below
stops the warnings. |
"Block" = the habit of including #ignore_warnings NONE after any #ignore_warnings x directive.
*smack* I'll leave that out this time.
--
Jeff S. |
|
|
object01
Joined: 13 May 2004 Posts: 90 Location: Nashville, TN
|
|
Posted: Mon Mar 28, 2005 9:38 am |
|
|
PCM programmer wrote: | Not sure what you mean by a "block". The placement shown below
stops the warnings.
Code: | #include <16F877.h>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#ignore_warnings 202
//--------------------------------------------
void main()
{
while(1);
} |
|
Well, I thought it'd work too... but it doesn't seem to do the trick. I've put it immediately before main(), immediately after my #use rs232 directives, immediately before them, etc. Even made it the first line in my program. No luck.
And I remembered why a single #ignore_warnings 202 line wasn't acceptable in the first place without an #ignore_warnings NONE; 'cause I want to be notified about all unused variables except rs232_errors.
--
Jeff S. |
|
|
bluetooth
Joined: 08 Jan 2005 Posts: 74
|
|
Posted: Mon Mar 28, 2005 6:51 pm |
|
|
Quote: |
And I remembered why a single #ignore_warnings 202 line wasn't acceptable in the first place without an #ignore_warnings NONE; 'cause I want to be notified about all unused variables except rs232_errors.
--
Jeff S. |
Then use my suggestion:
rs232_errors = 0;
inserted near the beginning of the program will eliminate the error.
Edited to add:
You can make this error go away WITHOUT generating code by defining a function you never call. In that function, put:
rs232_errors = 0;
This will satisfy the compiler that the variable was used, but the optimizer won't generate the code! |
|
|
|