3

I downloaded the Tessnet2 project from http://www.pixel-technology.com/freeware/tessnet2/ and I am able to build it fine in Visual Studio 2008. However, I need to recompile it for .NET 4. I know very little about C++, but the errors I am getting when i try to compile with VS 2010 are:

Error 4 error C2439: 'std::_Pair_base<_Ty1,_Ty2>::first' : member could not be initialized C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\utility 163 1 tessnet2

Error 6 error C2439: 'std::_Pair_base<_Ty1,_Ty2>::second' : member could not be initialized C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\utility 163 1 tessnet2

Error 3 error C2440: 'initializing' : cannot convert from 'int' to 'ScrollView *' C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\utility 163 1 tessnet2

Error 5 error C2440: 'initializing' : cannot convert from 'int' to 'SVEvent *' C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\utility 163 1 tessnet2

I'm assuming you can't just open a 2008 C++ project in 2010 and do a simple convert like most actual .NET projects. But, if anyone can give me some insight on this I appreciate it.

Josh Danko
  • 123
  • 9

1 Answers1

2

I had the same problem.

It seems that the VS2010 compiler is stricter about NULL being defined as a the literal 0 than the VS2008 one was. Therefore you must explicitly cast the NULL references in this project to their corresponding class types.

Specifically, you must make the following four changes to the scrollview.cpp file to get the project to compile:

-- Change line 137

std::pair<ScrollView*, SVEventType> awaiting_list_any_window(NULL,
                                                          SVET_ANY);                                                          

to

std::pair<ScrollView*, SVEventType> awaiting_list_any_window((ScrollView*)NULL,
                                                          SVET_ANY);

-- Change line 409

waiting_for_events[ea] = std::pair<SVSemaphore*, SVEvent*> (sem, NULL);

to

waiting_for_events[ea] = std::pair<SVSemaphore*, SVEvent*> (sem, (SVEvent*) NULL);

-- Change line 427

std::pair<ScrollView*, SVEventType> ea(NULL, SVET_ANY);

to

std::pair<ScrollView*, SVEventType> ea((ScrollView*)NULL, SVET_ANY);

-- Change line 429

waiting_for_events[ea] = std::pair<SVSemaphore*, SVEvent*> (sem, NULL);

to

waiting_for_events[ea] = std::pair<SVSemaphore*, SVEvent*> (sem, (SVEvent*) NULL);
Eternal Rubyist
  • 3,445
  • 4
  • 34
  • 51
  • Wouldn't using `nullptr_t` instead of NULL get the same results without the rather ugly cast? – Voo Jan 06 '12 at 20:57
  • @Voo I've never used nullptr_t, but when I tried replacing NULL with it just now I got an "Error: type name is not allowed" . – Eternal Rubyist Jan 06 '12 at 22:25
  • I assume you tried `std::nullptr_t` as well? Strange, I thought if they had a pointer in the definition and not an int this would work - strange, but then I'm far from an expert there. – Voo Jan 07 '12 at 00:27