|
|
View previous topic :: View next topic |
Author |
Message |
juhlin
Joined: 06 Feb 2004 Posts: 1
|
define for printf |
Posted: Fri Feb 06, 2004 2:45 am |
|
|
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 |
Posted: Sat Feb 07, 2004 6:58 pm |
|
|
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? |
|
|
|
|
|
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
|