C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

va_arg only for bult-in types?

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Derek Baker
Guest





PostPosted: Tue Sep 27, 2005 5:19 pm    Post subject: va_arg only for bult-in types? Reply with quote



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.

--
Derek

Back to top
Victor Bazarov
Guest





PostPosted: Tue Sep 27, 2005 5:32 pm    Post subject: Re: va_arg only for bult-in types? Reply with quote



Derek Baker wrote:
Quote:
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

Back to top
Derek Baker
Guest





PostPosted: Tue Sep 27, 2005 5:33 pm    Post subject: Re: va_arg only for bult-in types? Reply with quote



Derek Baker wrote:
Quote:
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.
--
Derek

Back to top
Derek Baker
Guest





PostPosted: Tue Sep 27, 2005 5:54 pm    Post subject: Re: va_arg only for bult-in types? Reply with quote

Victor Bazarov wrote:
Quote:
Derek Baker wrote:

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

Thanks Victor, it's running now with C strings.
--
Derek

Back to top
Ron Natalie
Guest





PostPosted: Fri Sep 30, 2005 7:36 pm    Post subject: Re: va_arg only for bult-in types? Reply with quote

Derek Baker wrote:
Quote:
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.

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.