compiling with VC++

Discussion in 'C++' started by T-Money, Aug 17, 2004.

  1. T-Money

    T-Money Guest

    I am trying to build an executable out of source code that supposedly
    compiles and is complete but i keep getting errors like the following:

    error C2664: cannot convert parameter 2 from
    'std::vector<_Ty>::iterator' to 'void *'
    with
    [
    _Ty=pseudoplot
    ]


    Looks to me like something is wrong with the code, but there shouldn't
    be. Does anyone know if there is a way to fix this in the compiler
    setting/environment.

    Thanks,
    T
     
    T-Money, Aug 17, 2004
    #1
    1. Advertising

  2. T-Money wrote:
    > I am trying to build an executable out of source code that supposedly
    > compiles and is complete but i keep getting errors like the following:
    >
    > error C2664: cannot convert parameter 2 from
    > 'std::vector<_Ty>::iterator' to 'void *'
    > with
    > [
    > _Ty=pseudoplot
    > ]
    >
    >
    > Looks to me like something is wrong with the code, but there shouldn't
    > be. Does anyone know if there is a way to fix this in the compiler
    > setting/environment.


    Not in this newsgroup. Try microsoft.public.vc.ide_general or any
    other suitable microsoft.public.vc.* newsgroup.

    If it's actually a problem with the code, we could try helping you,
    but you need to follow the recommendations in the FAQ 5.8.

    Victor
     
    Victor Bazarov, Aug 17, 2004
    #2
    1. Advertising

  3. T-Money

    Ali Cehreli Guest

    On Tue, 17 Aug 2004 12:01:22 -0700, T-Money wrote:

    > I am trying to build an executable out of source code that supposedly
    > compiles and is complete but i keep getting errors like the following:
    >
    > error C2664: cannot convert parameter 2 from
    > 'std::vector<_Ty>::iterator' to 'void *'
    > with
    > [
    > _Ty=pseudoplot
    > ]
    >
    >
    > Looks to me like something is wrong with the code, but there shouldn't
    > be.


    That code must be written under the assumption that vector::iterator is a
    typedef of T* (or convertible to T*). The implementation you are using
    probably defines vector::iterator as a class.

    For example this works with g++ 2.95:

    #include <vector>
    #include <iostream>

    using namespace std;

    void foo(int * i)
    {
    cout << *i << '\n';
    }

    int main()
    {
    vector<int> v;
    v.push_back(42);
    foo(v.begin());
    }

    > Does anyone know if there is a way to fix this in the compiler
    > setting/environment.


    You can rename functions like foo and call them through new functions:

    // Renamed
    void foo_impl(int * i)
    {
    cout << *i << '\n';
    }

    // Uses the address of the object
    void foo(vector<int>::iterator iter)
    {
    return foo_impl(&(*iter));
    }

    Ali
     
    Ali Cehreli, Aug 17, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jonas L

    VS is adding code when compiling

    Jonas L, Apr 1, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,038
    =?iso-8859-15?Q?Lasse_V=E5gs=E6ther_Karlsen?=
    Apr 1, 2004
  2. David Rainsford

    Compiling from the command line

    David Rainsford, May 4, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    653
    Tarundeep Singh Kalra
    May 6, 2004
  3. Garrett Cooper
    Replies:
    0
    Views:
    585
    Garrett Cooper
    Feb 24, 2009
  4. Garrett Cooper
    Replies:
    0
    Views:
    518
    Garrett Cooper
    Feb 24, 2009
  5. Lon Baker
    Replies:
    1
    Views:
    236
    Csaba Henk
    Mar 21, 2005
Loading...

Share This Page