View previous topic :: View next topic |
Author |
Message |
jmac_link
Joined: 28 Jun 2007 Posts: 9
|
#ignore_warnings macro |
Posted: Wed Aug 01, 2007 6:05 am |
|
|
Hi,
Im trying to make a macro to ignore compiler warnings:
Code: | #define WHILE_TRUE #ignore_warnings 203 while (1) { #ignore_warnings NONE
#define END_WHILE_TRUE }
WHILE_TRUE
do_something()
END_WHILE_TRUE
|
I get compiler error:
'Constant out of the valid range 0 is not 200..299'
for #ignore_warnings 203
(Ive also tried separating lines in the macro using \)
Is it that #ignore_warnings wont allow anything else except the warning number after it => this macro idea is doomed?
Thanks in advance,
John Mackenzie |
|
|
jmac_link
Joined: 28 Jun 2007 Posts: 9
|
|
Posted: Wed Aug 01, 2007 6:11 am |
|
|
Forgot -compiler version is 3.249 |
|
|
kevcon
Joined: 21 Feb 2007 Posts: 142 Location: Michigan, USA
|
|
Posted: Wed Aug 01, 2007 7:21 am |
|
|
try putting a semicolon after do_somthing( ) |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Aug 01, 2007 7:24 am |
|
|
is equivalent toThe latter doesn't generate a compiler warning.
If you don't like the for-loop construction you could write your DO_WHILE macro as Code: | #define DO_WHILE for(;;) { |
|
|
|
jmac_link
Joined: 28 Jun 2007 Posts: 9
|
|
Posted: Wed Aug 01, 2007 7:41 am |
|
|
Thanks ckielstra,
I never use for(;;) so hand't thought of using it!
Nice solution!
|
|
|
Mark Weir
Joined: 11 Sep 2003 Posts: 51 Location: New Zealand
|
Warnings |
Posted: Thu Aug 02, 2007 1:41 pm |
|
|
Why not just use # ignore_warnings 203,202 etc
As a pre processor directive.
Cheers
Mark _________________ Life is too short to avoid asking questions |
|
|
Fusillade
Joined: 02 Aug 2007 Posts: 31
|
Re: Warnings |
Posted: Fri Aug 10, 2007 2:50 pm |
|
|
Mark Weir wrote: | Why not just use # ignore_warnings 203,202 etc
As a pre processor directive.
Cheers
Mark |
He just wanted to replace:
#ignore_warnings 203
while (1)
{
#ignore_warnings NONE
with:
WHILE_TRUE
which would clean up his code, would easily port to other programs, and it would disable the warning 203 for the "while (1)" only.
jmac_link wrote: | Is it that #ignore_warnings wont allow anything else except the warning number after it => this macro idea is doomed? |
It appears to be doomed as the #ignore_warnings won't allow anything else except the warning numbers and commas after it. This includes comments.
It took me a bit to figure out why the following line continued to give me the same error as John:
#ignore_warnings 203 // ignore the warning for while(TRUE) |
|
|
jmac_link
Joined: 28 Jun 2007 Posts: 9
|
Re: Warnings |
Posted: Mon Aug 13, 2007 2:43 am |
|
|
Fusillade wrote: |
He just wanted to replace:
#ignore_warnings 203
while (1)
{
#ignore_warnings NONE
with:
WHILE_TRUE
which would clean up his code, would easily port to other programs, and it would disable the warning 203 for the "while (1)" only.
|
Exactly!!
In the end I used for(;;) instead because
a) #ignore_warnings doesnt allow anything after the number(s) on the same line
b) its cleaner. |
|
|
|