AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Coding MM:S Plugins & SM Extensions (https://forums.alliedmods.net/forumdisplay.php?f=75)
-   -   va_list function passing argument (https://forums.alliedmods.net/showthread.php?t=151586)

raydan 02-25-2011 08:28

va_list function passing argument
 
Code:

bool testfuc(void *in1, void *in2, ...)
{
  va_list arg;
  va_start(arg, in2);
  ...
  va_end(arg);
  return true;
}
 
// code 1
testfuc(NULL, NULL, 1, 2, 3);
 
// code 2
void *pp = &some_int;
testfuc(NULL, NULL, "a", pp, anotherint, 0.5f);
 
//code 3
testfunc(NULL, NULL, p3);

question is:
in code 3, how to pack/pass or do something to "p3", make the result same as code 1 & code 2?

PM 02-25-2011 09:08

Re: va_list function passing argument
 
What do you need this for and what is the exact use case? Do you know the number of arguments 'p3' should contain and their types at compile time?

If not, you'll probably have to push the arguments on the stack according to the calling convention ( __cdecl or some varaint ) yourself using inline assembly. That would not be very easy to do (because "basic" types, floating point types, bigger types (structs, classes) can be each passed in a different way + you should respect copy constructors etc. for structs and classes)


All times are GMT -4. The time now is 12:59.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.