Howdy, Stranger!

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

Categories

va_arg, va_start C++

ruipachecoruipacheco Member Posts: 20
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

  • DariusDarius Member Posts: 1,666
    : 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

  • Shawn CarterShawn Carter Member Posts: 0

    ___ / http://forcoder.org / free ebooks and video tutorials about || Python, C#, Scratch, Swift, JavaScript, C, Visual Basic, PHP, Ruby, PL/SQL, R, C++, Delphi, Perl, Go, Assembly, Visual Basic .NET, Objective-C, MATLAB, Java Dart, LabVIEW, Fortran, FoxPro, Julia, Lua, Crystal, Rust, Transact-SQL, Erlang, Scheme, Scala, Hack, Ada, SAS, ABAP, D, VBScript, Lisp, ML, Logo, F#, Alice, Clojure, COBOL, Apex, Kotlin, Prolog, Bash, Awk || __________

Sign In or Register to comment.