1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Using va_arg with pair<> container

Discussion in 'C++' started by Robi_Roman, Apr 8, 2010.

  1. Robi_Roman

    Robi_Roman New Member

    Joined:
    Apr 8, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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
     
    Last edited by a moderator: Apr 9, 2010

Share This Page