Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!unixhub!stanford.edu!leland.Stanford.EDU!dkeisen From: dkeisen@leland.Stanford.EDU (Dave Eisen) Newsgroups: comp.lang.c Subject: Re: #define problem Keywords: #define macro Message-ID: <1991Jun20.144228.25464@leland.Stanford.EDU> Date: 20 Jun 91 14:42:28 GMT References: <1991Jun20.051827.23428@ux1.cso.uiuc.edu> Organization: Sequoia Peripherals, Inc. Lines: 27 In article <1991Jun20.051827.23428@ux1.cso.uiuc.edu> J-Beauchamp@uiuc.edu writes: >I have many occurences of 'printf(' which I would like to replace with >'fprintf(stderr,' in my C program. Is there a way to do this #define? > >#define printf( fprintf(sterr, > I agree with another poster that the best way to do this is with a text editor. Still, there is a solution along the lines of what you tried. No, you can't define printf to be fprintf(stderr. But you can do the following: #define printf fprintf_stderr int fprintf_stderr (const char *fmt, ...) { va_list args; int ret; va_start (args, fmt) ret = vfprintf (stderr, fmt, args); va_end (args); return ret; }