Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uunet!lll-winken!llnl!wyrm!p0.f217.n914.z8.RBBS-NET.ORG!Dave.Giunti From: Dave.Giunti@p0.f217.n914.z8.RBBS-NET.ORG (Dave Giunti) Newsgroups: comp.lang.c Subject: #define problem Message-ID: <667.2865E0F5@wyrm.rbbs-net.ORG> Date: 24 Jun 91 03:47:00 GMT Sender: ufgate@wyrm.rbbs-net.ORG (newsout1.26) Organization: FidoNet node 8:914/217.0 - The PC GFX Exchange, San Francisco Lines: 53 reply to: >From: beaucham@uxh.cso.uiuc.edu (James Beauchamp) >Date: 20 Jun 91 05:18:27 GMT >Organization: University of Illinois at Urbana >Message-ID: <1991Jun20.051827.23428@ux1.cso.uiuc.edu> >Newsgroups: comp.lang.c JB> JB>I have many occurences of 'printf(' which I would like to replace with JB>'fprintf(stderr,' in my C program. Is there a way to do this #define? JB> JB>#define printf( fprintf(sterr, JB> JB>definitely doesn't parse. Hi Jim, I just tried to redefine some curses calls in this manner; unfortunatly you can't use a single '(' in a #define : it's a couples only dance. And you can't do a variable parameter pass inside the finger-nails. Catch 22... To try and get a little more performence out of Gnu Chess I was willing to do a little thinking. Here is a solution I found that worked: #ifdef MSDOS /* pre #defined by Microsoft C*/ #define printz fprintf /* curses to whatever I needed to test */ #define STDER stderr, /* or any other stream */ #else #define STDER /* a null declaration */ #endif then something like printz( STDER "this could go anywhere"); /* can have meaning */ It might be more usefull to have a couple of classes of defined output for various chanels. I should point out that I didn't get faster output from this and it bloated the code so I junked it... but I am almost positive I got the comma past the troll of defines. Dave at Fidonet 1:125/98 (Uhura) BTW Is anyone else out there hacking on Gnu Chess, either inside or outside MS DOS? * EZ 1.33 * -- Dave Giunti - via RBBS-NET node 8:914/201 INTERNET: Dave.Giunti@p0.f217.n914.z8.RBBS-NET.ORG