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

debug/release versions

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



Joined: 22 Feb 2006
Posts: 65

View user's profile Send private message

debug/release versions
PostPosted: Fri Nov 02, 2007 1:33 pm     Reply with quote

Hi all.
Can anybody point me to way of doing printf in debug version with a macro?
The same macro in "release" version would do nothing?
It's possible do do this with CCS C?
Thank you.
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Fri Nov 02, 2007 2:49 pm     Reply with quote

Did you try with #ifdef preprocessor directives?
I canĀ“t fully understand what do you need, please could you write an example of
what do you want to show/hide while in "debugg mode or in "release mode"?


Humberto
tavioman



Joined: 22 Feb 2006
Posts: 65

View user's profile Send private message

PostPosted: Fri Nov 02, 2007 4:08 pm     Reply with quote

A macro.
Code:
trace("Something %d, else %Ld", x, y);

that in release just won't do anything...
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Nov 02, 2007 4:33 pm     Reply with quote

Try this. It uses a debug macro from the CCS file Ex_Macro.c.
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)

//#define DEBUG 1

#ifdef DEBUG
#define debug_printf(x)   printf("%s variable value is %d\r\n",#x,x);
#else
#define debug_printf(x)   
#endif

//==================================
void main()
{
char c;

c = 0x55;

debug_printf(c);

while(1);
}
tavioman



Joined: 22 Feb 2006
Posts: 65

View user's profile Send private message

PostPosted: Sat Nov 03, 2007 12:44 am     Reply with quote

I wish to be more generic like:
Code:

trace("This is debug value no. %u with address %u", value, address);
trace("Just a line");
trace("Three numbers: %u, %u, %u", number1, number2, number3);

I believe this can be done with va_arg, etc.
I've never worked with this, and I don't know the usage....
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