Part of the code is as follows:
Va_start (ap, FMT);
The vsprintf (text, FMT, ap);
Va_end (ap);
Errors are: _va_start internal function only in varargs
CodePudding user response:
Va_start/va_end can only be used in C call methods (parameters into the stack from right to left, and released by the caller stack), and the parameters for the variable parameter (the number of parameters passed is not fixed) cases to be meaningful,
CodePudding user response:
reference 1st floor FASM_FASM response: va_start/va_end can only be used in C call way (parameters into the stack from right to left, and released by the caller stack), and the parameters for the variable parameter (the number of parameters passed is not fixed) cases to be meaningful, That is there any way to modify the program? I know into a stack of this knowledge is not a lot, CodePudding user response:
What is you this code in the function prototype, post and see, CodePudding user response:
reference ccrun reply: 3/f what is your this code in the function prototype, posted a look at GLvoid COpenglSet: : glPrint (const char * FMT, Cx, double double Cy, double Cz) { //BuildFont (); Float length=0;//2 To Find The Length Of The Text Char text [256].//doesn Our String Va_list ap;//Pointer To a List Of the Arguments If (FMT==NULL)//if There 's No Text return;//Do Nothing Va_start (ap, FMT);//Parses The String For The Variables //vsprintf (text, FMT=va_arg (ap, char *), ap); The vsprintf (text, FMT, ap);//And Converts Symbols To Actual Numbers Va_end (ap);//the Results Are Stored In Text For (unsigned int loop=0; Loop<(strlen (text)); Loop++)//Loop To Find Text Length { [loop length +=GMF [text]]. GmfCellIncX;//happens Length By Each Characters Width } GlPushMatrix (); GlTranslatef (Cx, Cy, Cz); GlTranslatef (0.0 - length/2, f, f);//Center Our Text On The Screen GlPushAttrib (GL_LIST_BIT);//whom The Display List Bits GlListBase (base);//Sets The Base Character to 0 GlCallLists (strlen (text), GL_UNSIGNED_BYTE, text);//Draws The Text Display List GlPopAttrib (); GlPopMatrix (); //remobilised The Display List Bits //KillFont (); } CodePudding user response:
I have written something like that before, so this is pretty much what, for your reference Int XXXXXX: : printf (const would * p_wszFormat,... ) { Va_list args. Va_start (args, p_wszFormat); Vsnwprintf (NULL, 0, p_wszFormat, args); Va_end (args); . } CodePudding user response:
C + + must have... The parameters used in the function of va_start CodePudding user response:
1/f, made it very clear, Simple said is the first function calling convention to use __cdecl or __stdcall, next parameters should have variable parameter "... " CodePudding user response:
The reference 7 floor ccrun response: 1/f, made it very clear, Simple said is the first function calling convention to use __cdecl or __stdcall, next parameters should have variable parameter "... " Variable-length argument cannot use stdcall CodePudding user response:
refer to the eighth floor akirya response: variable-length argument cannot use stdcall Try to know, I use for many years, # include & lt; Flags. H> Void __stdcall TfrmMain: : OutputLog (LPCWSTR MSG,... ) { Va_list ap; Va_start (ap, MSG); WCHAR buffer [2048]={0}; StringCchVPrintf (buffer, 2048, MSG, ap); Va_end (ap); If (mmoLog - & gt; Lines - & gt; The Count & gt; 4000) MmoLog - & gt; Lines - & gt; The Clear (); MmoLog - & gt; Lines - & gt; Add (buffer); } CodePudding user response:
1. In C, and when we can't list all the types of the arguments and the transfer function of the number, can use the ellipsis specified argument list Void foo (... ); Void foo (parm_list,... ); Are not this way and we know before, but we should remember this is a kind of spread and the form of C, we will use it in the rear, 2. The function parameter of the transmission principle of Function parameters based on data structures: stack, in the form of access, into the stack from right to left, First is the parameters of memory storage formats: is stored in the stack segment of memory, at the time of executive function, starting from the last into the stack, so the bottom of the stack high address, low stack address, for example as follows: Void func (int x, float y, char z); So, calls the function, the arguments advanced char z stack, then the float y, finally the int x, so in memory variables to store order is X-ray & gt; Y - & gt; Z, so, in theory, we just detect any the address of a variable, and know the type of other variables, through a pointer shift operation, the total can ultimately find other input variables, The following is & lt; Stdarg. H> Important inside a few macros are defined as follows: Typedef char * va_list; Void va_start (va_list ap, prev_param);/* */ANSI version Type va_arg (va_list ap, type); Void va_end (va_list ap); Va_list is a character pointer, which can be understood as a pointer points to the current parameters, take must be conducted by the pointer, For example, int Max (int n,... ); His function should be implemented: #include Void fun (int a,... ) { Int * temp=& amp; a; Temp++; for (int i=0; i { Cout & lt; <* temp & lt; Temp++; } } Int main () { Int a=1; Int b=2; Int c=3; int d=4; Fun (4, a, b, c, d); system("pause"); return 0; } Output: : 1 2 3 4 nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull