Note that there are some explanatory texts on larger screens.

plurals
  1. POcreating va_list dynamically in GCC - can it be done?
    primarykey
    data
    text
    <p>my problem with <code>vsprintf</code> is that I can not obtain input arguments directly, I have to first get inputs one by one and save them in <code>void**</code>, then pass this <code>void**</code> to <code>vsprintf()</code>, it is all fine for windows, but when I come to 64bit linux, gcc cannot compile because it is not allowed to convert from <code>void**</code> to <code>va_list</code>, Is there anyone that can give me some help how I should do this under linux? </p> <p><strong>Can I create va_list dynamically in GCC?</strong></p> <pre><code>void getInputArgs(char* str, char* format, ...) { va_list args; va_start(args, format); vsprintf(str, format, args); va_end(args); } void process(void) { char s[256]; double tempValue; char * tempString = NULL; void ** args_ptr = NULL; ArgFormatType format; //defined in the lib I used in the code int numOfArgs = GetNumInputArgs(); // library func used in my code if(numOfArgs&gt;1) { args_ptr = (void**) malloc(sizeof(char)*(numOfArgs-1)); for(i=2; i&lt;numOfArgs; i++) { format = GetArgType(); //library funcs switch(format) { case ArgType_double: CopyInDoubleArg(i, TRUE, &amp;tempValue); //lib func args_ptr[i-2] = (void*) (int)tempValue; break; case ArgType_char: args_ptr[i-2]=NULL; AllocInCharArg(i, TRUE, &amp;tempString); //lib func args_ptr[i-2]= tempString; break; } } } getInputArgs(s, formatString, (va_list) args_ptr); //Here // is the location where gcc cannot compile, // Can I and how if I can create a va_list myself? } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload