Original Post
Hello, I am having a problem with va_lists this is a simplified example of what I am trying to do... unfortunately the arg.pObj when inspected later doesn't seem to be functioning correctly... the parameters are all garbage If I, instead, manually create my param with the following function it works as expected: I am not sure why the va_arg method is causing the program to get messed up. as I am only passing a pointer i don't see why it would be a problem to retrieve the pointer... Any help would be appreciated.
struct param
{
union{
int i;
float f;
...
BaseObj* ptr
};
TYPEID type;
};
param myfunc(const char* types, ...)
{
TYPEID type = parse_type(types);
va_list arguments;
va_start( arguments, types );
param arg;
switch(type)
{
...
case TYPE_BASE_OBJECT:
arg.type = TYPE_BASE_OBJECT;
arg.ptr = va_arg ( arguments, BaseObj* );
}
va_end ( arguments );
return arg;
}
param addObject(std::string varname, BaseObj* pObj)
{
param arg;
arg.data.pObj = pObj;
arg.type_id = TYPE_BASE_OBJECT;
return arg;
}