 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Derek Baker Guest
|
Posted: Tue Sep 27, 2005 5:19 pm Post subject: va_arg only for bult-in types? |
|
|
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
|
Posted: Tue Sep 27, 2005 5:32 pm Post subject: Re: va_arg only for bult-in types? |
|
|
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
|
Posted: Tue Sep 27, 2005 5:33 pm Post subject: Re: va_arg only for bult-in types? |
|
|
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
|
Posted: Tue Sep 27, 2005 5:54 pm Post subject: Re: va_arg only for bult-in types? |
|
|
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
|
Posted: Fri Sep 30, 2005 7:36 pm Post subject: Re: va_arg only for bult-in types? |
|
|
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 |
|
 |
|
|
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
|
|