Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > compiling with VC++

Reply
Thread Tools

compiling with VC++

 
 
T-Money
Guest
Posts: n/a
 
      08-17-2004
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
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      08-17-2004
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
 
Reply With Quote
 
 
 
 
Ali Cehreli
Guest
Posts: n/a
 
      08-17-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Cross-compiling error when compiling 2.6.1... Garrett Cooper Python 0 02-24-2009 09:47 PM
Cross-compiling error when compiling 2.6.1... Garrett Cooper Python 0 02-24-2009 08:55 PM
Compiling when libedit is in path Is there a trick to compiling Ruby when libedit must exist in the search path? Can you statically link to readline 5.0 in some manner? -- Lon Baker Lon Baker Ruby 1 03-21-2005 08:57 AM
Compiling from the command line David Rainsford ASP .Net 4 05-06-2004 02:03 PM
VS is adding code when compiling Jonas L ASP .Net 1 04-01-2004 02:27 PM



Advertisments