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

preprocessor instruction ifdef with fuses

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



Joined: 23 Jan 2007
Posts: 2
Location: Bournemouth

View user's profile Send private message MSN Messenger

preprocessor instruction ifdef with fuses
PostPosted: Tue Jan 23, 2007 7:48 am     Reply with quote

Hello everybody!

I would like to know if that code will execute the code

#fuses NODEBUG

#IFDEF NODEBUG

code

#ENDIF

Is that the correct way to execute some code depending if I am in debug mode?

Thanks a lot!
Ttelmah
Guest







PostPosted: Tue Jan 23, 2007 9:23 am     Reply with quote

At heart, no...
Fuses, are completely separate, from 'defines', which #ifdef, and #ifndef access. 'Defines', set values, which are accessed during the preprocessor phase (which CCS does not explicitly have as a distinct compiler phase), but still handles like other compilers in general. 'fuses', set specific bits in the processor configuration words.
However, CCS, has an extra instruction, to 'join' these two functions. There is a command:

FUSE_SET:fffff (where 'fffff' is a fuse name), which returns a '1', that can be tested in the preprocessor commands, to do what you want.
So:

#IF getenv("FUSE_SET:DEBUG")!=1


#ENDIF

Will perform the lines between the #if, and the #endif, if the debug mode fuse is not set.

Best Wishes
joviwap



Joined: 23 Jan 2007
Posts: 2
Location: Bournemouth

View user's profile Send private message MSN Messenger

PostPosted: Tue Jan 23, 2007 5:50 pm     Reply with quote

Thank you very much. I knew that was not right but is the best y could found for my selve.

Anyway, I going to use this new instruction!

Thanx again!
Ttelmah
Guest







PostPosted: Wed Jan 24, 2007 3:05 am     Reply with quote

If you look in the file 'readme.txt', in your compiler's home directory, it has details of some of the other 'extra bits' like this. Smile

Best Wishes
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Wed Jan 24, 2007 7:02 am     Reply with quote

Another approach:

Code:

#define NO_DEBUG

#ifdef NO_DEBUG
  #fuses NODEBUG
#else
  #fuses DEBUG
#endif
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