Common Build Errors

Everything about development and the OpenMW source code.
Locked
User avatar
lgromanowski
Site Admin
Posts: 1151
Joined: 05 Aug 2011, 22:21
Location: Wroclaw, Poland
Github profile: https://github.com/lgromanowski
Contact:

Common Build Errors

Post by lgromanowski » 15 Aug 2011, 09:12

jhooks1 wrote: I thought I would post up an error I received in Visual Studio 2010 / VC10 and how to fix it.

1>------ Build started: Project: openmw, Configuration: Release Win32 ------
1> layouts.cpp
1>c:\u\openmw\libs\mangle\stream\servers\std_stream.hpp(34): warning C4244: 'return' : conversion from 'std::streamsize' to 'size_t', possible loss of data
1>c:\u\openmw\libs\mangle\stream\servers\std_stream.hpp(47): warning C4244: 'return' : conversion from 'std::streamoff' to 'size_t', possible loss of data
1>c:\u\openmw\libs\mangle\stream\servers\std_stream.hpp(54): warning C4244: 'initializing' : conversion from 'std::streamoff' to 'size_t', possible loss of data
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\utility(163): error C2440: 'initializing' : cannot convert from 'int' to 'MyGUI::StaticTextPtr '
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\utility(247) : see reference to function template instantiation 'std::_Pair_base<_Ty1,_Ty2>::_Pair_base<int&,_Ty>(_Other1,_Other2 &&)' being compiled
1> with
1> [
1> _Ty1=int,
1> _Ty2=MyGUI::StaticTextPtr ,
1> _Ty=int,
1> _Other1=int &,
1> _Other2=int
1> ]
1> ..\..\..\apps\openmw\mwgui\layouts.cpp(58) : see reference to function template instantiation 'std::pair<_Ty1,_Ty2>::pair<int&,int>(_Other1,_Other2 &&)' being compiled
1> with
1> [
1> _Ty1=int,
1> _Ty2=MyGUI::StaticTextPtr ,
1> _Other1=int &,
1> _Other2=int
1> ]
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\utility(163): error C2439: 'std::_Pair_base<_Ty1,_Ty2>::second' : member could not be initialized
1> with
1> [
1> _Ty1=int,
1> _Ty2=MyGUI::StaticTextPtr
1> ]
1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\utility(167) : see declaration of 'std::_Pair_base<_Ty1,_Ty2>::second'
1> with
1> [
1> _Ty1=int,
1> _Ty2=MyGUI::StaticTextPtr
1> ]
1> review.cpp
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\utility(163): error C2440: 'initializing' : cannot convert from 'int' to 'MyGUI::StaticTextPtr '
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\utility(247) : see reference to function template instantiation 'std::_Pair_base<_Ty1,_Ty2>::_Pair_base<int&,_Ty>(_Other1,_Other2 &&)' being compiled
1> with
1> [
1> _Ty1=int,
1> _Ty2=MyGUI::StaticTextPtr ,
1> _Ty=int,
1> _Other1=int &,
1> _Other2=int
1> ]
1> ..\..\..\apps\openmw\mwgui\review.cpp(83) : see reference to function template instantiation 'std::pair<_Ty1,_Ty2>::pair<int&,int>(_Other1,_Other2 &&)' being compiled
1> with
1> [
1> _Ty1=int,
1> _Ty2=MyGUI::StaticTextPtr ,
1> _Other1=int &,
1> _Other2=int
1> ]
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\utility(163): error C2439: 'std::_Pair_base<_Ty1,_Ty2>::second' : member could not be initialized
1> with
1> [
1> _Ty1=int,
1> _Ty2=MyGUI::StaticTextPtr
1> ]
1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\utility(167) : see declaration of 'std::_Pair_base<_Ty1,_Ty2>::second'
1> with
1> [
1> _Ty1=int,
1> _Ty2=MyGUI::StaticTextPtr
1> ]
1> Generating Code...
2>------ Skipped Build: Project: ALL_BUILD, Configuration: Release Win32 ------
2>Project not selected to build for this solution configuration
========== Build: 0 succeeded, 1 failed, 5 up-to-date, 1 skipped ==========


To fix it add a cast like so on line 58 of layouts.cpp:

Code: Select all

BEFORE:  skillWidgetMap.insert(std::pair<int, MyGUI::StaticTextPtr>(i, nullptr));
FIXED:  skillWidgetMap.insert(std::pair<int, MyGUI::StaticTextPtr>(i, (MyGUI::StaticTextPtr) nullptr));
Add another cast to line 83 of review.cpp:

Code: Select all

BEFORE:skillWidgetMap.insert(std::pair<int, MyGUI::StaticTextPtr>(i, nullptr));
FIXED:skillWidgetMap.insert(std::pair<int, MyGUI::StaticTextPtr>(i, (MyGUI::StaticTextPtr) nullptr));

Feel free to post other common build errors you have had and how to fix them in this thread (on any platform).

sir_herrbatka Edit: Sticky now
athile wrote: I updated my branch with a build fix for the insert() error. The problem is that MyGUI is redefining nullptr to 0. That's bad for VS2010 since nullptr is a C++0x keyword. A "better" fix, IMHO, is to update the CMake file to take advantage of the MyGUI preprocessor define that will not redefine nullptr:

add_definitions(-DMYGUI_DONT_REPLACE_NULLPTR)
Star-Demon wrote: Awesome. Thanks for making life less stressful for us VS folks.
best regards,
Lukasz

Locked

Who is online

Users browsing this forum: No registered users and 2 guests