Connecting Tech Pros Worldwide Help | Site Map

compiling with VC++

  #1  
Old July 22nd, 2005, 06:59 PM
T-Money
Guest
 
Posts: n/a
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
  #2  
Old July 22nd, 2005, 06:59 PM
Victor Bazarov
Guest
 
Posts: n/a

re: compiling with VC++


T-Money wrote:[color=blue]
> 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.[/color]

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
  #3  
Old July 22nd, 2005, 06:59 PM
Ali Cehreli
Guest
 
Posts: n/a

re: compiling with VC++


On Tue, 17 Aug 2004 12:01:22 -0700, T-Money wrote:
[color=blue]
> 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.[/color]

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());
}
[color=blue]
> Does anyone know if there is a way to fix this in the compiler
> setting/environment.[/color]

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
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems after compiling with Multithreaded-DLL runtime library Andreas Schmitt answers 9 April 11th, 2007 10:45 PM
how to make a win32 dll with VC++ express Lloyd Dupont answers 1 November 19th, 2005 01:55 PM
MSVCR71.DLL with VC 7.0 ? Fabuio answers 1 November 17th, 2005 05:23 PM
Compiling with VC++ Toolkit 2003 Ioannis Vranos answers 1 November 17th, 2005 04:42 PM