Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Using va_arg with pair<> container (http://www.go4expert.com/forums/using-vaarg-pair-container-t21710/)

Robi_Roman 9Apr2010 02:18

Using va_arg with pair<> container
 
Hello,

I have been trying to compile my code but getting compilers error. I am unable to fix the problem and couldn't find any solution further in the net. If anyone knows how to use stl container "pair" as an argument to va_arg( ) macro pl let me know. My code snipet is as follows.....N.B:The compiler is giving error for the line va_arg(pa, pair<string,int>):

Thanks
Robi.
Code:


#include "stdafx.h"
#include "stdarg.h"
#include <iostream>
#include <string>
#include <utility>
using namespace std;
 
pair <string,int>FlyStick("FlyStick",7);
pair <string,int>Head("Head",11);
pair <string,int> Belt("Belt",13);
pair <string,int> Glove("Glove",17);

typedef struct buffer
{
string Name;
int ID;
}buffer;
 
void TestVa(pair<string,int>,...);
 
int main(int argc, char* argv[])
{
 
 TestVa(FlyStick,Head,,Belt, -1);

  return 0;
}
 
void TestVa(pair<string,int> iDevice,...)
{
int i,j;
int NumOfDevices=0;
i=0;
j=0;
 
va_list pa;
va_start(pa,iDevice);
 
ziggs* buffer=new ziggs[4];
buffer[0].ID=iDevice.second;
buffer[0].Name=iDevice.first;
 
cout<<buffer[0].Name<<"  "<<buffer[0].ID<<endl;
 
//while(i!=1)
//{
 
//NumOfDevices++;
 
va_arg (pa,pair<string,int>);    <========error here

...........rest of the code........
};

Compilers Msg:

:\Program Files\Microsoft Visual Studio\MyProjects\TestPair\TestPair.cpp(66) : error C2143: syntax error : missing ',' before ')'
C:\Program Files\Microsoft Visual Studio\MyProjects\TestPair\TestPair.cpp(66) : error C2143: syntax error : missing ',' before ')'
C:\Program Files\Microsoft Visual Studio\MyProjects\TestPair\TestPair.cpp(66) : error C2059: syntax error : ')'
C:\Program Files\Microsoft Visual Studio\MyProjects\TestPair\TestPair.cpp(66) : error C2059: syntax error : ')'
C:\Program Files\Microsoft Visual Studio\MyProjects\TestPair\TestPair.cpp(66) : error C2059: syntax error : ')'
C:\Program Files\Microsoft Visual Studio\MyProjects\TestPair\TestPair.cpp(66) : error C2143: syntax error : missing ',' before ')'
C:\Program Files\Microsoft Visual Studio\MyProjects\TestPair\TestPair.cpp(66) : error C2059: syntax error : ')'
C:\Program Files\Microsoft Visual Studio\MyProjects\TestPair\TestPair.cpp(66) : error C2059: syntax error : ')'
C:\Program Files\Microsoft Visual Studio\MyProjects\TestPair\TestPair.cpp(66) : error C2059: syntax error : ')'
C:\Program Files\Microsoft Visual Studio\MyProjects\TestPair\TestPair.cpp(66) : error C2059: syntax error : ')'
C:\Program Files\Microsoft Visual Studio\MyProjects\TestPair\TestPair.cpp(76) : error C2143: syntax error : missing ';' before '}'
C:\Program Files\Microsoft Visual Studio\MyProjects\TestPair\TestPair.cpp(77) : error C2143: syntax error : missing ';' before '}'
C:\Program Files\Microsoft Visual Studio\MyProjects\TestPair\TestPair.cpp(77) : fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'YĆ', line 1)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information


All times are GMT +5.5. The time now is 22:45.