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

prototype of fprintf function in ccs

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



Joined: 27 Dec 2012
Posts: 2

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

prototype of fprintf function in ccs
PostPosted: Thu Dec 27, 2012 4:09 am     Reply with quote

I'm trying to get fprintf function working only when DEBUG is defined. This worked ok for printf, but it seems I can't get the right prototype for fprintf function.

Code:
#ifdef DEBUG
   #define debug_printf fprintf
#else
   #define debug_printf fprintf_dummy
#endif

void fprintf_dummy(char *string, char *format, ...){

}   


I get compiler error: "Attempt to create a pointer to a constant"

Is there any better way to do it? I would like to have debug_printf function that I can use as a standard printf. For example:
Code:
void debug_printf(char *format, ...){
#IFDEF DEBUG
  fprintf(RS232_DEBUG, ........); // I'm not sure how to pass all parameters to fprintf function
#ENDIF
}   
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Thu Dec 27, 2012 6:23 am     Reply with quote

Try this link

http://www.ccsinfo.com/forum/viewtopic.php?t=47206&highlight=technique

Mike
labyte



Joined: 27 Dec 2012
Posts: 2

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

PostPosted: Fri Dec 28, 2012 8:38 am     Reply with quote

Thank you Mike for the link. For now, gribas proposed best solution with #define trace... I was hoping for a little bit more elegant solution, but this will do.
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