Results 1 to 2 of 2
Hi Guys,
I have a problem creating va_list variable on zLinux platform.
Here is the code that i had written to create va_list variable
va_list INVALID_VA_LIST = NULL;
va_list bar(void ...
- 03-27-2008 #1Just Joined!
- Join Date
- Mar 2008
- Posts
- 1
Problem creating va_list variable on zLinux
Hi Guys,
I have a problem creating va_list variable on zLinux platform.
Here is the code that i had written to create va_list variable
va_list INVALID_VA_LIST = NULL;
va_list bar(void **vals)
{
int numvals=0;
void **out=NULL;
for (numvals = 0; vals[numvals]; ++numvals) {}
out = (void **)malloc (numvals * sizeof (void *));
if (!out)
return INVALID_VA_LIST;
memcpy (out, vals, sizeof (void *) * numvals);
return (va_list)out;
}
int main() {
const char *lists[] = { "hi", "ho", "off we go", NULL };
va_list arglist = bar((void**)lists);
char *vval;
while((vval = va_arg(arglist, char *)) != NULL){
printf("%s\n",vval);
}
This use to work on Linux platform (Like Red Hat, Suse), but this is not working in zLinux platform and i could not find any work around for this, since i have to pass dynemic number of arguments to a function i want to create the va_list varialbe.
As per some forums i have read that va_list in zLinux is a structure, can any one help me creating a va_list variable on zLinux platform.
Thanks in advance...
- 03-27-2008 #2
It is never a good idea to pretend to know the internals of a variable of type va_list. The C standard allows the implementer to structure it any way he or she wishes, as long as it behaves as documented.
The only permissible ways to manipulate a variable of type va_list is with the following.
- va_start()
- va_arg()
- va_end()
- va_copy()
(I was about to say "with the following functions", but you should not assume that none of them are macros.)
For more information about these, do this at the command line:
If man pages are not installed on your system, google this:Code:man 3 stdarg
It does not appear that stdarg is what you want to use here.Code:man stdarg Linux
Instead, just use a pointer of pointers to void, as you're already doing, and pass that back and forth.
Hope this helps.--
Bill
Old age and treachery will overcome youth and skill.


Reply With Quote