View previous topic :: View next topic |
Author |
Message |
joviwap
Joined: 23 Jan 2007 Posts: 2 Location: Bournemouth
|
preprocessor instruction ifdef with fuses |
Posted: Tue Jan 23, 2007 7:48 am |
|
|
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
|
|
Posted: Tue Jan 23, 2007 9:23 am |
|
|
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
|
|
Posted: Tue Jan 23, 2007 5:50 pm |
|
|
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
|
|
Posted: Wed Jan 24, 2007 3:05 am |
|
|
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.
Best Wishes |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Wed Jan 24, 2007 7:02 am |
|
|
Another approach:
Code: |
#define NO_DEBUG
#ifdef NO_DEBUG
#fuses NODEBUG
#else
#fuses DEBUG
#endif
|
|
|
|
|