Problem Compiling CEGUI Under VC10

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

Cypherjb
Not too shy to talk
Not too shy to talk
Posts: 22
Joined: Thu Jun 04, 2009 05:11

Problem Compiling CEGUI Under VC10

Postby Cypherjb » Tue Jul 21, 2009 12:25

Trying to get CEGUI compiling under VC10 but not having much luck. I know this won't be officially supported, but I figured someone might have a fix anyway.

The one place the build fails for me is in CEGUIMultiColumnList:
1> CEGUIMultiColumnList.cpp
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\xmemory(205): error C2440: 'initializing' : cannot convert from 'int' to 'CEGUI::ListboxItem *'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\xmemory(288) : see reference to function template instantiation 'void std::allocator<_Ty>::construct<int>(CEGUI::ListboxItem **,_Other &&)' being compiled
1> with
1> [
1> _Ty=CEGUI::ListboxItem *,
1> _Other=int
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(659) : see reference to function template instantiation 'void std::_Cons_val<std::allocator<_Ty>,CEGUI::ListboxItem*,int>(_Alloc &,_Ty1 *,_Ty2 &&)' being compiled
1> with
1> [
1> _Ty=CEGUI::ListboxItem *,
1> _Alloc=std::allocator<CEGUI::ListboxItem *>,
1> _Ty1=CEGUI::ListboxItem *,
1> _Ty2=int
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(679) : see reference to function template instantiation 'void std::vector<_Ty>::emplace_back<int>(_Valty &&)' being compiled
1> with
1> [
1> _Ty=CEGUI::ListboxItem *,
1> _Valty=int
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(666) : see reference to function template instantiation 'std::_Vector_iterator<_Myvec> std::vector<_Ty>::emplace<int>(std::_Vector_const_iterator<_Myvec>,_Valty &&)' being compiled
1> with
1> [
1> _Myvec=std::_Vector_val<CEGUI::ListboxItem *,std::allocator<CEGUI::ListboxItem *>>,
1> _Ty=CEGUI::ListboxItem *,
1> _Valty=int
1> ]
1> c:\users\administrator\documents\visual studio 10\projects\cegui-0.6.2\src\elements\ceguimulticolumnlist.cpp(702) : see reference to function template instantiation 'std::_Vector_iterator<_Myvec> std::vector<_Ty>::insert<int>(std::_Vector_const_iterator<_Myvec>,_Valty &&)' being compiled
1> with
1> [
1> _Myvec=std::_Vector_val<CEGUI::ListboxItem *,std::allocator<CEGUI::ListboxItem *>>,
1> _Ty=CEGUI::ListboxItem *,
1> _Valty=int
1> ]
1> CEGUIMenuItem.cpp

Here's the structure definition that contains the offending vector:
struct ListRow
{
typedef std::vector<ListboxItem*> RowItems;
RowItems d_items;
uint d_sortColumn;
uint d_rowID;

// operators
ListboxItem* const& operator[](uint idx) const {return d_items[idx];}
ListboxItem*& operator[](uint idx) {return d_items[idx];}
bool operator<(const ListRow& rhs) const;
bool operator>(const ListRow& rhs) const;
};

Here's the function that fails in the STL:
template<class _Other>
void construct(pointer _Ptr, _Other&& _Val)
{ // construct object at _Ptr with value _Val
::new ((void _FARQ *)_Ptr) _Ty(_STD forward<_Other>(_Val));
}
#endif /* _HAS_RVALUE_REFERENCES */

This seems to be the only point of failure, but I don't know much about the new rvalue reference stuff so I was wondering if anyone knew of a way to fix this.

Thanks.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Problem Compiling CEGUI Under VC10

Postby CrazyEddie » Wed Jul 22, 2009 08:51

I tried to get this error here on g++. I got the error in relation to something in an Ogre header, but not from the CEGUI code.

Looking at it, it seems likely that it's taking a zero as an integer rather than as a null pointer, if that is the case, the fix will involve casting the 0 to ListboxItem*. From a cursory look, it could be the initialisation lines at 811 and 875 in CEGUIMultiColumnList.cpp - not 100% certain though.

HTH

CE.

Cypherjb
Not too shy to talk
Not too shy to talk
Posts: 22
Joined: Thu Jun 04, 2009 05:11

Re: Problem Compiling CEGUI Under VC10

Postby Cypherjb » Wed Jul 22, 2009 13:38

Gave it a try but it's still not taking unfortunately.

row.d_items.resize(getColumnCount(), static_cast<ListboxItem*>(0));

Made the modification to both lines but to no avail. :(

Thanks for the try though, appreciated. Can you think of anything else that might cause it?

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Problem Compiling CEGUI Under VC10

Postby CrazyEddie » Wed Jul 22, 2009 19:34

Hmm. Can't think of anything else, if fact I'd say that's almost certainly the cause - but perhaps the fix was in the wrong place :?: When you click the error in the IDE where does it take you in the source?

CE

Cypherjb
Not too shy to talk
Not too shy to talk
Posts: 22
Joined: Thu Jun 04, 2009 05:11

Re: Problem Compiling CEGUI Under VC10

Postby Cypherjb » Thu Jul 23, 2009 05:22

CrazyEddie wrote:Hmm. Can't think of anything else, if fact I'd say that's almost certainly the cause - but perhaps the fix was in the wrong place :?: When you click the error in the IDE where does it take you in the source?

CE


To the STL headers unfortunately. Lol.

The actual source of the error message is in the STL headers not your code.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Problem Compiling CEGUI Under VC10

Postby CrazyEddie » Thu Jul 23, 2009 08:25

Yeah, that's 'cos they're templates. I'll maybe do some digging later today and see what I can come up with.

CE.

Zeph
Just popping in
Just popping in
Posts: 1
Joined: Sat Nov 28, 2009 17:32

Re: Problem Compiling CEGUI Under VC10

Postby Zeph » Sat Nov 28, 2009 17:38

I had this very same problem around 15 minutes ago, and I found the error to be at line 702 of CEGUIMultiColumnList.cpp.

Code: Select all

d_grid[i].d_items.insert(d_grid[i].d_items.begin() + position, 0);

is to be changed to

Code: Select all

d_grid[i].d_items.insert(d_grid[i].d_items.begin() + position, nullptr);


In visual studio 2010 (when adapting new c++ standard) they killed some emerging problems by adding a new keyword to represent a pointer that points nowhere "nullptr" instead of using an integer "0". It shouldn't matter if you mix your own code with that "0" and nullptr, but when using STL containers you should stick to "nullptr" from now on.

For more information, refer to http://en.wikipedia.org/wiki/C%2B%2B0x#Null_pointer_constant or http://msdn.microsoft.com/en-us/library/4ex65770(VS.100).aspx

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Re: Problem Compiling CEGUI Under VC10

Postby scriptkid » Tue Dec 01, 2009 10:08

Hi,

Thanks for sharing this! It seems that they have made things much even more tight this round.
Check out my released snake game using Cegui!

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Problem Compiling CEGUI Under VC10

Postby CrazyEddie » Wed Dec 02, 2009 10:14

Yeah, indeed. Thanks for the solution here. Slight PITA from a backwards compatibility point of view I think, but should be workable.

CE.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 30 guests