va_arg only for bult-in types?

D

Derek Baker

I have this code which compiles on the MINGW version of GCC 3.4.2:

vector<string> Labels ;
va_list va_Labels;

va_start(va_Labels, Number);

for(int i= 0; i< Number; ++i)
{
Labels.push_back(va_arg(va_Labels, string));
}

va_end(va_Labels);

It compiles, but cause a segmentation fault when run. I have similar
code that extracts ints and it runs fine.
 
V

Victor Bazarov

Derek said:
I have this code which compiles on the MINGW version of GCC 3.4.2:

vector<string> Labels ;
va_list va_Labels;

va_start(va_Labels, Number);

for(int i= 0; i< Number; ++i)
{
Labels.push_back(va_arg(va_Labels, string));
}

va_end(va_Labels);

It compiles, but cause a segmentation fault when run. I have similar
code that extracts ints and it runs fine.

To answer the question in the subject line, yes, only for built-in types.

V
 
D

Derek Baker

Derek said:
I have this code which compiles on the MINGW version of GCC 3.4.2:

vector<string> Labels ;
va_list va_Labels;

va_start(va_Labels, Number);

for(int i= 0; i< Number; ++i)
{
Labels.push_back(va_arg(va_Labels, string));
}

va_end(va_Labels);

It compiles, but cause a segmentation fault when run. I have similar
code that extracts ints and it runs fine.

It is on the "Labels.push_back(va_arg(va_Labels, string));" line that
the fault occurs.
 
R

Ron Natalie

Derek said:
I have this code which compiles on the MINGW version of GCC 3.4.2:
It doesn't have to be a built in type, it can be a class as long as the
class is POD.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top