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 CCS Technical Support

#ignore_warnings macro

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



Joined: 28 Jun 2007
Posts: 9

View user's profile Send private message Visit poster's website

#ignore_warnings macro
PostPosted: Wed Aug 01, 2007 6:05 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Wed Aug 01, 2007 6:11 am     Reply with quote

Forgot -compiler version is 3.249
kevcon



Joined: 21 Feb 2007
Posts: 142
Location: Michigan, USA

View user's profile Send private message

PostPosted: Wed Aug 01, 2007 7:21 am     Reply with quote

try putting a semicolon after do_somthing( )
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed Aug 01, 2007 7:24 am     Reply with quote

Code:
while (1)
is equivalent to
Code:
for(;;)
The 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

View user's profile Send private message Visit poster's website

PostPosted: Wed Aug 01, 2007 7:41 am     Reply with quote

Thanks ckielstra,

I never use for(;;) so hand't thought of using it!

Nice solution!

Very Happy
Mark Weir



Joined: 11 Sep 2003
Posts: 51
Location: New Zealand

View user's profile Send private message

Warnings
PostPosted: Thu Aug 02, 2007 1:41 pm     Reply with quote

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

View user's profile Send private message

Re: Warnings
PostPosted: Fri Aug 10, 2007 2:50 pm     Reply with quote

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

View user's profile Send private message Visit poster's website

Re: Warnings
PostPosted: Mon Aug 13, 2007 2:43 am     Reply with quote

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.
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