va_arg, va_start C++

Hi
I have a function that receives an unknown number of parameters, and to get them I use the library. I wrote the code this way:

void cmdlog::logger( string linha, ... ){

va_list lista_parametros;
va_start( lista_parametros, linha.c_str() );

safety_measures();
write_log( linha, lista_parametros );
cleanup();

va_end( lista_parametros );
}

but when I compile it finishes with a warnig:
warning: second parameter of `va_start' not last named argument

How can I solve this? Has anyone sucessfully used va_args in C++? I've already tried google but it was no good. :|

thanks
Rui Pacheco

Comments

  • : Hi
    : I have a function that receives an unknown number of parameters, and to get them I use the library. I wrote the code this way:
    :
    : void cmdlog::logger( string linha, ... ){
    :
    : va_list lista_parametros;
    : va_start( lista_parametros, linha.c_str() );
    :
    : safety_measures();
    : write_log( linha, lista_parametros );
    : cleanup();
    :
    : va_end( lista_parametros );
    : }
    :
    : but when I compile it finishes with a warnig:
    : warning: second parameter of `va_start' not last named argument
    :
    : How can I solve this? Has anyone sucessfully used va_args in C++? I've already tried google but it was no good. :|
    :
    : thanks
    : Rui Pacheco
    :

    The last named argument is 'linha', not 'linha.c_str()'.

    "We can't do nothing and think someone else will make it right."
    -Kyoto Now, Bad Religion

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion