I have zillions of my_printf () function calls in a huge program. Now I want to convert them all so that the function accepts a new integer argument (name it x) without changing the number of calls. If my_printf used only one string argument, I could do something like this:
#define my_printf(str) _my_printf(x,str) void _my_printf(int x,char *str)
But since my_printf takes a variable number of arguments, I'm not sure how to do this. It can be done?
EDIT: for those who are wondering why I should do such a thing, here is an example:
#if BELT_AND_BRACES_DIAGNOSTIC_MODE #define function(x) _function(__FILE__,__LINE__,x) #else // speed critical optimised mode #define function(x) _function(x) #endif #if BELT_AND_BRACES_DIAGNOSTIC_MODE void _function(char *file,int line,int x) #else void _function(int x) #endif { // stuff #if BELT_AND_BRACES_DIAGNOSTIC_MODE if (something_went_wrong) { printf("Cock up in function when called from %s line %d\n",file,line); } #endif }
c
Mick
source share