[GRASS-dev] g.rename consolidation
Glynn Clements
glynn at gclements.plus.com
Fri Feb 23 12:44:08 EST 2007
Martin Landa wrote:
> > You would need a version of the callee which takes a va_list as a
> > parameter, and I'm not sure whether there's any portable way to write
> > such functions.
>
> OK,
>
> /*!
> * \fn void G_message_ex (char *msg,...)
> *
> * \brief Print a message to stderr only on the given verbosity level or greater
> *
> * The output format depends on enviroment variable GRASS_MESSAGE_FORMAT
> *
> * \param level verbosity level
> */
> void G_message_ex (int level, char *msg,...)
> {
> char buffer[2000]; /* G_asprintf does not work */
> va_list ap;
>
> va_start(ap, msg);
> vsprintf(buffer,msg,ap);
> va_end(ap);
>
> if (G_verbose() >= level) {
> print_error (buffer,MSG);
> }
> }
>
> anyway is not nice way. Duplicate the code. Last time I have tried to
> write G_message_no_line() I had similar problem.
I don't see a problem here; the va_start/vsprintf/va_end part is
pretty much inevitable for any variadic function.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list