From: "David Whitcombe" Newsgroups: comp.os.msdos.djgpp Subject: Re: Allegro: How to wrap "..." argumentlist Date: Wed, 30 Jun 1999 23:46:54 -0600 Organization: Rocky Mountain Internet - 1(800)-900-RMII Lines: 51 Message-ID: <7levm8$kn3$1@news1.rmi.net> References: <8D53104ECD0CD211AF4000A0C9D60AE30146182F AT probe-2 DOT acclaim-euro DOT net> NNTP-Posting-Host: 209.38.35.81 X-Trace: news1.rmi.net 930808328 21219 209.38.35.81 (1 Jul 1999 05:52:08 GMT) X-Complaints-To: abuse AT rmi DOT net NNTP-Posting-Date: 1 Jul 1999 05:52:08 GMT X-Newsreader: Microsoft Outlook Express 4.72.3155.0 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Shawn Hargreaves wrote in message <8D53104ECD0CD211AF4000A0C9D60AE30146182F AT probe-2 DOT acclaim-euro DOT net>... >A. Jans-Beken writes: >>This works all fine. But now I want to wrap this function... >> >> textprintf(BITMAP *bmp, FONT *f, int x, y, color, char *fmt, ...); >> >>I do not understand how to do this. The C++ primer that I have (old >>edition) is inconclusive. A gues would be: >> >> void textprintf(int x, y, color, char *fmt, ... ) { >> ::textprintf(bob, font, x, y, color, fmt, ... ); >> } > >Alternatively, there is a gcc extension that can help with this >situation: see info "c extensions" "constructing calls". I'm not >sure if this will work with a C++ method, though. > > Sorry if this is off topic, but when I wrapped textprintf() into my own Allegro class, I just ended up calling va_start() and vsprintf()... I have a BmpType class with a member function Printf(const char *fmt, ...) It looks kinda like this: void BmpType::Printf(const char *format, ...) { char *buffer = new char[2048]; va_list arg; va_start(arg, format); vsprintf(buffer, format, arg); va_end(arg); Print(buffer); // buffer is de-allocated automatically when it goes out of scope. } Of course, if you're gonna print more than 2k strings, you need to do something clever :) (Or just not print such huge damned strings :) > Shawn Hargreaves.