problem compiling on visual studio 2008

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

problem compiling on visual studio 2008

Glenn Conner
I'm trying to upgrade a solution from visual studio 2005 to 2008 and I've come across the following error when trying to compile my solution. My code compiles fine under visual studio 2005 but in 2008 I get the following error. I'm fairly certain its a problem with luabind and not with my own code (though if someone could prove the contrary that would be fine with me :))

luabind\detail\policy.hpp(486) : error C2770: invalid explicit template argument(s) for 'luabind::detail::class_rep *luabind::detail::get_class_rep(lua_State *,void (__cdecl *)(T))'

now after having a look around it seems that visual studio 2008 treats template specializations differently than 2005, I found a post where someone has experienced a similar issue unrelated to luabind
http://groups.google.com/group/microsoft.public.vc.language/browse_thread/thread/17c940ca65db9c4a/0d39aeb73606414a?#0d39aeb73606414a

Though after attempting a few unsuccessful changes to the luabind code, I'm pretty much clueless as to how to fix it (I find it hard to get my head around some of the template metaprogramming in luabind). Has anyone out there experienced this problem, and perhaps more importantly does anyone have a solution?

Cheers, Glenn.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: problem compiling on visual studio 2008

Glenn Conner
After looking into the problem more closely, I've isolated the cause down to this function in luabind/detail/class_cache.hpp

    template<class T>
    class_rep* get_class_rep(lua_State* L, void(*)(T) = 0)
    {
        class_registry* registry = class_registry::get_registry(L);
        return registry->find_class(LUABIND_TYPEID(T));
    }

where T is an abstract class, for example the following fails on visual studio 2008 but compiles fine on visual studio 2005.

class Foo
{
public:
    virtual void F(void)=0;
};

lua_State *ls;
class_rep* crep = get_class_rep<Foo>(ls);//will not compile on vs2008, compiles fine on vs2005

I've also produced a more general case fault below that is not specific to luabind and seems to illustrate the problem

class Foo
{
public:
    virtual void F(void)=0;
};

class Bar
{};

template<class T>
Bar* GetBar(void(*)(T) = 0)
{
    return new Bar();
}

Bar* bar = GetBar<Foo>(); //will not compile on vs2008, compiles fine on vs2005

Does anyone out there have any ideas regarding a fix or workaround to this issue?


On Sat, Feb 9, 2008 at 1:31 AM, Glenn Conner <[hidden email]> wrote:
I'm trying to upgrade a solution from visual studio 2005 to 2008 and I've come across the following error when trying to compile my solution. My code compiles fine under visual studio 2005 but in 2008 I get the following error. I'm fairly certain its a problem with luabind and not with my own code (though if someone could prove the contrary that would be fine with me :))

luabind\detail\policy.hpp(486) : error C2770: invalid explicit template argument(s) for 'luabind::detail::class_rep *luabind::detail::get_class_rep(lua_State *,void (__cdecl *)(T))'

now after having a look around it seems that visual studio 2008 treats template specializations differently than 2005, I found a post where someone has experienced a similar issue unrelated to luabind
http://groups.google.com/group/microsoft.public.vc.language/browse_thread/thread/17c940ca65db9c4a/0d39aeb73606414a?#0d39aeb73606414a

Though after attempting a few unsuccessful changes to the luabind code, I'm pretty much clueless as to how to fix it (I find it hard to get my head around some of the template metaprogramming in luabind). Has anyone out there experienced this problem, and perhaps more importantly does anyone have a solution?

Cheers, Glenn.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: problem compiling on visual studio 2008

James Porter-2
On Feb 11, 2008 3:22 AM, Glenn Conner <[hidden email]> wrote:
> I've also produced a more general case fault below that is not specific to
> luabind and seems to illustrate the problem
[snip]
> Does anyone out there have any ideas regarding a fix or workaround to this
> issue?

It's probably choking on the function pointer in get_class_rep, since
it takes an object of type T by value, and that's not going to work
very well for an abstract class. :) I'm pretty sure the "void(*)(T) =
0" is in there just for compatibility with old compilers, and you
should be able to remove it. I don't have access to VS2008 at the
moment, so I can't be 100% sure, though...

As a permanent fix, you/we could probably change "void(*)(T) = 0" to
"void(*)(T*) = 0".

- Jim

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: problem compiling on visual studio 2008

Glenn Conner
As a permanent fix, you/we could probably change "void(*)(T) = 0" to
"void(*)(T*) = 0".

This worked perfectly, thanks!

Who do we need to contact in order to submit this as a patch into the luabind trunk?

On Tue, Feb 12, 2008 at 8:01 AM, James Porter <[hidden email]> wrote:
On Feb 11, 2008 3:22 AM, Glenn Conner <[hidden email]> wrote:
> I've also produced a more general case fault below that is not specific to
> luabind and seems to illustrate the problem
[snip]
> Does anyone out there have any ideas regarding a fix or workaround to this
> issue?

It's probably choking on the function pointer in get_class_rep, since
it takes an object of type T by value, and that's not going to work
very well for an abstract class. :) I'm pretty sure the "void(*)(T) =
0" is in there just for compatibility with old compilers, and you
should be able to remove it. I don't have access to VS2008 at the
moment, so I can't be 100% sure, though...

As a permanent fix, you/we could probably change "void(*)(T) = 0" to
"void(*)(T*) = 0".

- Jim

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: problem compiling on visual studio 2008

Evan Wies
in the patches section of the Luabind Sourceforge page:

http://sourceforge.net/tracker/?group_id=77060&atid=549060

-Evan

Glenn Conner wrote:

> As a permanent fix, you/we could probably change "void(*)(T) = 0" to
> "void(*)(T*) = 0".
>
> This worked perfectly, thanks!
>
> Who do we need to contact in order to submit this as a patch into the
> luabind trunk?
>
> On Tue, Feb 12, 2008 at 8:01 AM, James Porter <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     On Feb 11, 2008 3:22 AM, Glenn Conner <[hidden email]
>     <mailto:[hidden email]>> wrote:
>     > I've also produced a more general case fault below that is not
>     specific to
>     > luabind and seems to illustrate the problem
>     [snip]
>     > Does anyone out there have any ideas regarding a fix or workaround
>     to this
>     > issue?
>
>     It's probably choking on the function pointer in get_class_rep, since
>     it takes an object of type T by value, and that's not going to work
>     very well for an abstract class. :) I'm pretty sure the "void(*)(T) =
>     0" is in there just for compatibility with old compilers, and you
>     should be able to remove it. I don't have access to VS2008 at the
>     moment, so I can't be 100% sure, though...
>
>     As a permanent fix, you/we could probably change "void(*)(T) = 0" to
>     "void(*)(T*) = 0".
>
>     - Jim
>
>     -------------------------------------------------------------------------
>     This SF.net email is sponsored by: Microsoft
>     Defy all challenges. Microsoft(R) Visual Studio 2008.
>     http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>     _______________________________________________
>     luabind-user mailing list
>     [hidden email]
>     <mailto:[hidden email]>
>     https://lists.sourceforge.net/lists/listinfo/luabind-user
>
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> luabind-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/luabind-user


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user