Mail Archives: djgpp/1997/03/14/19:00:08
Paul Derbyshire writes:
>#define textoutf(b,f,fmt,x,y,c,args...) ({ char foobuf[256];\
> sprintf (foobuf,fmt, ## args);\
> textout (b,f,foobuf,x,y,c);\
> })
I actually already have such a routine in the version sitting on my hard
drive, called textprintf (thanks to Ron T Lewis who suggested it).
Thanks for the idea, anyway!
>(I tried making this as a function and could not figure out how to pass a
>runtime variable number of args to sprintf. I assumed just passing my
It can be done with varargs and the vsprintf() function from libc.
Personally I dislike using macros for things like this, because of the
huge potential for unexpected side effects. Since gcc supports inline
functions in C code, there really isn't any need to use macros...
>#define trapmalloc(amt,type,errfunc) ({ type *fooptr;\
> fooptr=(type)malloc(amt*sizeof(type));\
> if (!fooptr) errfunc();\
> fooptr;\
Do you really think this is relevant to this group? By all means share
your neat ideas with us, but on glancing through the posts sent to the
group today, I notice that over a quarter of them are from you. Is there
any chance you could filter your thoughts a bit, and only post the ones
that seem particularly enlightening and/or relevant to djgpp? (please
remember that general C coding issues are not included in the group
charter).
/*
* Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
* Beauty is a French phonetic corruption of a short cloth neck ornament.
*/
- Raw text -