| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| tavioman 
 
 
 Joined: 22 Feb 2006
 Posts: 65
 
 
 
			    
 
 | 
			
				| debug/release versions |  
				|  Posted: Fri Nov 02, 2007 1:33 pm |   |  
				| 
 |  
				| 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
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri Nov 02, 2007 2:49 pm |   |  
				| 
 |  
				| 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
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri Nov 02, 2007 4:08 pm |   |  
				| 
 |  
				| 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
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri Nov 02, 2007 4:33 pm |   |  
				| 
 |  
				| 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
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Sat Nov 03, 2007 12:44 am |   |  
				| 
 |  
				| 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....
 |  | 
	
		|  | 
	
		|  |