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 CCS Technical Support

define for printf

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



Joined: 06 Feb 2004
Posts: 1

View user's profile Send private message

define for printf
PostPosted: Fri Feb 06, 2004 2:45 am     Reply with quote

Hi

Does someone know who to do a #define with unknown number of parameters, for printf ? Here is what I want to do (in valid GCC syntax)

#define lprintf(text...) printf(lcd_putc, text)

And now it's possible todo the following :

lprintf("hello world");
lprintf("number of i is %d", d);
lprintf("file %s on line %d", __FILE__, __LINE__);

Unfortanly CCS complain about me define. Is it possible to use any other syntax to get what I want?
Guest








Re: define for printf
PostPosted: Sat Feb 07, 2004 6:58 pm     Reply with quote

In the distant past, I used this form using doubled parentheses. I haven't tried it on CCS, but it has worked on other compilers.

NB: You can make an ugly mess of your code doing this. At least *I* have.

Code:
#define lprintf(x) printf x
main()
{
   lprintf(("Testing %d %d %d\r\n", 1, 2, 3));
}


juhlin wrote:
Hi

Does someone know who to do a #define with unknown number of parameters, for printf ? Here is what I want to do (in valid GCC syntax)

#define lprintf(text...) printf(lcd_putc, text)

And now it's possible todo the following :

lprintf("hello world");
lprintf("number of i is %d", d);
lprintf("file %s on line %d", __FILE__, __LINE__);

Unfortanly CCS complain about me define. Is it possible to use any other syntax to get what I want?
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