From: Paul S. <pa...@is...> - 2000-11-16 02:11:48
|
Hello Ales, Ales Teska <te...@to...> wrote on Wednesday, November 15, 2000: AT> Hi, AT> this is maybe off-topic question. AT> I want in one of my headers to change this : AT> Log(int ID,char *Text, ...); AT> in to this : AT> LogFnct(MODULE_NAME,int ID,char *Text, ...); AT> LogFnct is a library function with variable no. of params. AT> I tried to : AT> #define Log(x,y) LogFnct(MODULE_NAME,x,y) AT> It works, but the "variable" arguments were lost AT> This : AT> #define Log( LogFnct(MODULE_NAME, AT> didn`t work, preprocesor destroyed whole line, where its appers. Preprocessor macros should be a proper syntactic construct, not like the last example. AT> So question is how to use macros (#define) to substitute function AT> with variable arguments. Or do you have another solution(s). ;)) Standard idiom is: #define DEBUG(x) if (debug) printf x DEBUG(("foo=%d\n",foo)) but that won't work for you. Then, use gcc extension: #define foo(args...) bar(foobar, ## args) AT> Just shine AT> Alex -- Paul Sokolovsky, IT Specialist http://www.brainbench.com/transcript.jsp?pid=11135 |