Article View: comp.os.msdos.programmer
Article #2729Re: #define thisneatmacro
From: Markus Fischer
Date: Fri, 19 Oct 1990 15:38
Date: Fri, 19 Oct 1990 15:38
42 lines
1570 bytes
1570 bytes
In article <9286@helios.TAMU.EDU>, ctl8588@rigel.tamu.edu (LAUGHLIN, CHET)
writes:
>
> [...]
>
> I tried useing the following macro, with some success...
>
> #define drawch(A,B,C) {gotoxy(A,B); cput(C);}
>
> however, the following code won't work...compiler doesn't like
> the extra ; at the end of drawch...
>
> if (cond)
> drawch(x,y,ch);
> else
> printf("ICK!\n");
>
> Any ideas out there?
If you really want it, try one of the following:
#define drawch(A,B,C) do { gotoxy((A),(B)); cput(C); } while(0)
#define drawch(A,B,C) gotoxy((A),(B)), cput(C)
#define drawch(A,B,C) cputc(( gotoxy((A),(B)), (C) ))
whichever you like.
All four (your's included) follow the general rule for lowercase macros,
which is to use every parameter exaclty once. Thus
drawch( col++, row, *(string++) );
works as expected.
The last one is neat, it reads: call function cputc with parameter
"( evaluate gotoxy, with params A and B, drop the return value, use C )",
and keep return value of cputc for future use. ( In fact the equivalent
`putch' of TC returns nothing... )
Enjoy
Markus Fischer, Dpt. of Anthopology, Geneva.
Technical Details
Message-ID:
<275@sc2a.unige.ch>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!cernvax!chx400!ugun2b!ugsc2a!fisherReferences:
<9286@helios.TAMU.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!cernvax!chx400!ugun2b!ugsc2a!fisher From: fisher@sc2a.unige.ch (Markus Fischer) Newsgroups: comp.os.msdos.programmer Subject: Re: #define thisneatmacro Message-ID: <275@sc2a.unige.ch> Date: 19 Oct 90 15:38:08 GMT References: <9286@helios.TAMU.EDU> Organization: University of Geneva, Switzerland Lines: 42