[SOLVED] Compiling errors with MSVC 2010

Hey !

I’m porting my project to Windows now. After hours of yelling at vc’s developers for their incredibly shitty and incomplete implementation of C++11, I finished solving all the issues coming directly from my code.

What’s left is a recurrent compilation error with socket_portable.h.

C:\Program Files\Microsoft Visual Studio 10.0\VC\include\xxresult(28): error C2825: '_Fty': must be a class or namespace when followed by '::'
          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\xxresult(40) : see reference to class template instantiation 'std::tr1::_Result_type2<__formal,_Fty,_Arg0,_Arg1>' being compiled
          with
          [
              __formal=false,
              _Fty=__w64 unsigned int,
              _Arg0=std::tr1::_Nil &,
              _Arg1=std::tr1::_Nil &
          ]
          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\xxresult(597) : see reference to class template instantiation 'std::tr1::_Result_of2<_Fty,_Farg0,_Farg1>' being compiled
          with
          [
              _Fty=__w64 unsigned int,
              _Farg0=std::tr1::_Nil &,
              _Farg1=std::tr1::_Nil &
          ]
          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\xrefwrap(28) : see reference to class template instantiation 'std::tr1::_Result_of<_Ty>' being compiled
          with
          [
              _Ty=__w64 unsigned int (std::tr1::_Nil &,std::tr1::_Nil &)
          ]
          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\xxbind1(273) : see reference to class template instantiation 'std::tr1::result_of<_Fty>' being compiled
          with
          [
              _Fty=__w64 unsigned int (std::tr1::_Nil &,std::tr1::_Nil &)
          ]
          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\xxbind0(10) : see reference to class template instantiation 'std::tr1::_Bind2<_Callable,_Arg0,_Arg1>::_Return<_Barg0,_Barg1,_Barg2,_Barg3,_Barg4,_Barg5,_Barg6,_Barg7,_Barg8,_Barg9>' being compiled
          with
          [
              _Callable=std::tr1::_Callable_obj<SOCKET,false>,
              _Arg0=const sockaddr *,
              _Arg1=unsigned int,
              _Barg0=std::tr1::_Nil &,
              _Barg1=std::tr1::_Nil &,
              _Barg2=std::tr1::_Nil &,
              _Barg3=std::tr1::_Nil &,
              _Barg4=std::tr1::_Nil &,
              _Barg5=std::tr1::_Nil &,
              _Barg6=std::tr1::_Nil &,
              _Barg7=std::tr1::_Nil &,
              _Barg8=std::tr1::_Nil &,
              _Barg9=std::tr1::_Nil &
          ]
          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\functional(408) : see reference to class template instantiation 'std::tr1::_Bind_base<_Ret,_BindN>' being compiled
          with
          [
              _Ret=std::tr1::_Notforced,
              _BindN=std::tr1::_Bind2<std::tr1::_Callable_obj<SOCKET,false>,const sockaddr *,unsigned int>
          ]
          c:\panda3d-1.8.0\my_include\panda3d\socket_portable.h(82) : see reference to class template instantiation 'std::tr1::_Bind_fty<_Fty,_Ret,_BindN>' being compiled
          with
          [
              _Fty=SOCKET,
              _Ret=std::tr1::_Notforced,
              _BindN=std::tr1::_Bind2<std::tr1::_Callable_obj<SOCKET,false>,const sockaddr *,unsigned int>
          ]
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\xxresult(28): error C2903: 'result' : symbol is neither a class template nor a function template
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\xxresult(28): error C2039: 'result' : is not a member of '`global namespace''
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\xxresult(28): error C2143: syntax error : missing ';' before '<'
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\xxresult(28): error C2039: 'type' : is not a member of '`global namespace''
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\xxresult(28): error C2238: unexpected token(s) preceding ';'
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\xxresult(40): error C2039: '_Type' : is not a member of 'std::tr1::_Result_type2<__formal,_Fty,_Arg0,_Arg1>'
          with
          [
              __formal=false,
              _Fty=__w64 unsigned int,
              _Arg0=std::tr1::_Nil &,
              _Arg1=std::tr1::_Nil &
          ]
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\xxresult(40): error C2146: syntax error : missing ';' before identifier '_Type'
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\xxresult(40): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\xxresult(40): error C2602: 'std::tr1::_Result_of2<_Fty,_Farg0,_Farg1>::_Type' is not a member of a base class of 'std::tr1::_Result_of2<_Fty,_Farg0,_Farg1>'
          with
          [
              _Fty=__w64 unsigned int,
              _Farg0=std::tr1::_Nil &,
              _Farg1=std::tr1::_Nil &
          ]
          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\xxresult(40) : see declaration of 'std::tr1::_Result_of2<_Fty,_Farg0,_Farg1>::_Type'
          with
          [
              _Fty=__w64 unsigned int,
              _Farg0=std::tr1::_Nil &,
              _Farg1=std::tr1::_Nil &
          ]
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\xxresult(40): error C2868: 'std::tr1::_Result_of2<_Fty,_Farg0,_Farg1>::_Type' : illegal syntax for using-declaration; expected qualified-name
          with
          [
              _Fty=__w64 unsigned int,
              _Farg0=std::tr1::_Nil &,
              _Farg1=std::tr1::_Nil &
          ]
c:\panda3d-1.8.0\my_include\panda3d\socket_portable.h(82): error C2440: 'return' : cannot convert from 'std::tr1::_Bind_fty<_Fty,_Ret,_BindN>' to 'int'
          with
          [
              _Fty=SOCKET,
              _Ret=std::tr1::_Notforced,
              _BindN=std::tr1::_Bind2<std::tr1::_Callable_obj<SOCKET,false>,const sockaddr *,unsigned int>
          ]
          No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

I’m using Panda3D 1.8.0 and Visual Studio 2010.
Is there any compilation option I need to add ?

Also, this looks strangely like a network thing. I don’t use any piece of Panda3D for network. If this compilation error isn’t normal, maybe getting rid of everything related to network in Panda3D would do the trick. Is it possible to do so without recompiling Panda3D ?

[SOLVED]
Alright, I’ve managed to compile Panda3D with MSVC2010. I also wrote a manual to explain how to build my project. There’s mostly stuff on how to compile Panda3D and libRocket, and the things to do so they don’t collide:

code.google.com/p/fallout-equest … i/MSVC2010

With this heat, it’s getting dangerous for me to compile stuff and using the computer at the same time, so I didn’t try without the --no-python option. But it might work.

Actually, after looking at the header, this looks like an actual error.
When using C++, I’m pretty sure you need to write ::bind instead of bind. Otherwise it might conflict with the std, provided that some specific std headers are included.

It’s very bizarre that it happens in a header though… the std namespace is obviously not used, I don’t understand why msvc confuses it with std::bind.
It seems it does though. When I open the file in Visual Studio and hover the function, Visual Studio understands that it is a call to std::bind. When adding the two semicolons however, it sees it as a call to bind from the wsa lib.

EDIT: And yeah, the compiling error also disappeared.
It still seems weird to me, but it might be safer to add these semicolons.

RE-EDIT:
Somewhat related to the topic, here is another error, this time with Rocket and Panda3D:

C:\Users\lovestospooge\Desktop\libRocket\Include\Rocket/Core/Variant.inl(80): error C2011: '<unnamed-tag>' : 'enum' type redefinition
          c:\panda3d-1.8.0\my_include\panda3d\time_base.h(40) : see declaration of '<unnamed-tag>'

Fucking MSVC. There are an unnamed enum in Rocket, another one in Panda3D, and that makes a freaking conflict. This is freaking ridiculous.

not really MSVCs fault to be honest, I’d look in the mirror before blaming others :slight_smile:

As far as I know, I haven’t done anything. How am I supposed to figure out what I have done wrong ?

Upping this, the issue was reproduced by someone else who was in contact with me recently.

His instructions were basically to first build Panda3D, and he met the same issue than me with MSVC confusing ::bind for std::bind. Replacing ‘bind’ with ‘::bind’ also worked for him.
He was compiling with Visual Studio 2010.

I merely sent a single mail to that guy, and he hadn’t even pulled my project ! I don’t think either me or my code base are that contagious ! There’s probably something really going on. Are you sure Panda3D builds flawlessly with MSVC2010 ?

Kind out of topic but: Re-thinking about this:

Or maybe you should take a better look at MSVC… should we talk about the incredibly late arrival of variadic templates or about the clumsy implementation of lambdas ? I also noticed these kind of name issues very often with MSVC… I actually do think it’s MSVC’s fault: MSVC just sucks at solving names. And at a few others things, but most of all solving names.

A few years ago I had no experience with MSVC so I just thought, like you, that it was all my fault. Now I have a better understanding of how MSVC’s do things… and I can tell you it’s wrong.
Whatever the reason for this happening is, be it some faulty default configuration or actual bugs in the compiler, it’s wrong and there’s no reason for such things happening.

There are also good things in MSVC of course. It has a usually very academic implementation of the standards for instance. But there are quite crappy things too, like what I mentioned earlier, and less academic implementations of more obscure standards of C++.

Hmm, this is the first I’ve seen this thread–please do try to use respectful language in posts, people, and be mindful of “clever” comments that might just come out sounding snarky.

In this particular case, I think the problem is probably the <winsock.h> header file. MSVS has two different (and incompatible) versions of the winsock library, called <winsock.h> and <winsock2.h>. You can’t include both of them into the same project, or you get mysterious compilation errors like this.

Panda uses <winsock2.h>. Unfortunately, if you include <windows.h> before including any Panda header file, that file may automatically include <winsock.h>. So you have to explicitly include <winsock2.h> first (or change the include order so that you include Panda before you include any Windows header files).

David

Just for the record, we don’t officially support MSVC 2010 so we don’t claim that Panda builds flawlessly with it. There have been reports of people who had luck with it, though, but if you want to simply build Panda3D without issues you should download 2008.
(So many strange things change with each new release of MSVC that it’s simply not worth it for us to keep porting it every other year. That said, it might be time for us to start looking into porting Panda to the next one in the series sometime soon.)

For what it’s worth, none of the MSVC releases claim to support fully C++11 or even C++0x; these are very recent developments to the language that are not widely supported yet, so for portability reasons, it is probably wise not to rely too much on C++11 features.

They do support some C++11 features, though, such as std::bind, which explains why we haven’t seen the issue before-- in earlier versions, there simply was no ambiguity here. I’ve picked up the ::bind fix for 1.8.2, thanks.

I dug my own grave, my project extensively uses C++11 features. It’s not really that I didn’t know Panda3D officially didn’t support MSVC2010: rather that I didn’t know MSVC2008 didn’t support lambdas (which are vital to a signal/slot system that pretty much runs everything around the game).
I already had a lot of work removing C++11 features to get things working on MSVC2010 (it supports most of C++11, but not variadic templates). Doing so with MSVC2008 is downright impossible, the whole design is built around lambdas, and lambdas only started being implemented in the 2010 version.

At least I know a couple of people who managed to get Panda3D building with MSVC2010, and one of them even got my project running with it, so it might work out in the end.

From what I’ve witnessed it seems you are not that far from supporting MSVC2010, but I understand that it would probably be a better strategy to wait for the next version before making a move.

Sorry, I’m not trying to be offensive.
I just find that MSVC take its sweet time to implement new features (that are widely present in every concurrent)… and I am then astonished to see that despite the time they take, it seems they sometime get away from standard-compliance. It’s like VC isn’t really a C++ compiler, rather a compiler for something else that behaves a lot like C++ but not quite so.
And it’s frustrating because I’ve found no one to confirm or refute these assertions. I have nothing to compare to my point of view, which makes it impossible to make up my mind about the matter.

As a result, when I get an answer as simple as that, I’m just hanging for more. Looking on my side was already as fruitful as it can get: I need data which doesn’t come from me.

It’s not the place to start rambling over MSVC… but since the little quantity of C++ developer i know is exclusively gcc, I don’t really have anywhere else to raise the subject !

Perhaps you can more easily migrate to Boost lambdas instead?

That’s a solution but I would rather keep it as a last resort. It would require a considerable amount of changes. I’ve never used Boost lambdas but from the documentation, it looks like it provides all the features from , provided that I use them with boost::function and boost::bind.

It will probably be easier to get a build on MSVC2010. After all I know some people who managed to do it, and I helped them achieve the feat. It shouldn’t be that hard.
Plus I’m pretty sure that compiling with --no-python should remove the most troublesome issues. I know it’s not an option for most people, but from what I remember the only complicated issues that are popping out come from python support.

I’ll keep the topic opened until I have a build, just in case. I might learn stuff that will be useful to others.

did you have any luck with vc2010 ?

also I am curious as to why lambda is so important for what you are trying to do. I must admit I hadn’t heard of it before and I read the wiki page about the topic but I am still wondering why they are so important to make your game, what do you gain from it ?

I did, but with no python bindings (also I didn’t test with them, so it might still work… but from what I’ve heard from someone in my current project, it will cause issues).

I wrote a manual for developers of my project:

code.google.com/p/fallout-equest … pendencies
It goes over the compiling of both Panda3D and libRocket, in case you need it too (libRocket is MSVC2010 compliant, however once you compile your project you’ll find out that some of the headers conflicts with Panda3D).

About lambas, they’re a really amazing bunch.
Did you ever use the Qt library ? They made their own tool, qmake, to extend C++ features and implement signal/slot behaviors.
Using the new C++11 lambdas, I quickly implemented a similar signal/slot event. It’s basically a templated Observer design pattern.
In another project, I actually extended the class to the point that you can develop a game engine that is both single and multiplayer with the exact same code: the signals can be indifferently connected both to local and/or remote code.

I also worked on Rocket events with lambdas: it basically allows to bind to interfaces in RML/C++ the way you would do in HTML/Javascript.

So yeah. Lambdas are awesome.
Though MSVC’s implementation is kinda crappy… it’s ok as long as you only make lambdas, it’s utter crap if you start making lambda inside lambdas. Which is a rare occurrence, but can still reveal very useful: indeed, lambdas are not only good for event-driven development, they can also replace any functor you would have to write for 's templates (like std::for_each).

thanks for the answer, I am indeed using Q but only for my editor I wasn’t going to use Qt for actual game code.