From: Hans-Bernhard Broeker Newsgroups: comp.os.msdos.djgpp Subject: Re: How to write #define with several args Date: 5 Apr 2000 15:43:29 GMT Organization: Aachen University of Technology (RWTH) Lines: 23 Message-ID: <8cfmv1$grd$1@nets3.rz.RWTH-Aachen.DE> References: <8cfir5$2kui$1 AT news DOT itfs DOT nsk DOT su> NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de X-Trace: nets3.rz.RWTH-Aachen.DE 954949409 17261 137.226.32.75 (5 Apr 2000 15:43:29 GMT) X-Complaints-To: abuse AT rwth-aachen DOT de NNTP-Posting-Date: 5 Apr 2000 15:43:29 GMT Originator: broeker@ To: djgpp AT Delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Michael N. Filippov wrote: > Does anybody know how could i write #define to use it with > not predefined number of args. Example: In standard C, as defined in 1989, you can't. The new standard revision, and GCC as an existing extension, support it, but for those, you've got the syntax wrong. > #include > #define P(format, s) printf(format, s) // this is for one argument > #define MP(format, ...) printf(format, ...) // error Make that line #define MP(format, ...) printf(format, __VA_ARGS__) and it may work. Or look up the correct syntax in the GNU cpp manual ('info cpp'). -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.