YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

[SQRAT] GCC 4.6.1 compilation fails
Shikken
#1 Posted : Saturday, July 07, 2012 10:45:00 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/27/2012(UTC)
Posts: 4
Location: Poland

Thanks: 1 times
Was thanked: 0 time(s) in 0 post(s)
Hello,
i've come up with a problem recently

Code:
class BaseClass
{
public:
    int baseVariable;
};

class TestClass : public BaseClass
{
public:
    int testVar;
};

Class<TestClass> testClass(vm);
testClass.Var("testVar", &TestClass::testVar); // works
testClass.Var("baseVariable", &TestClass::baseVariable); // isn't working


The problem is that gcc is not accepting variables and functions from inherited classes, im using TDM-GCC 4.6.1-tdm64-1 and 4.7.1 on linux.
Gcc gives me this error while compiling:
Code:

error: no matching function for call to 'Sqrat::Class<TestClass>::Var(const char [13], int BaseClass::*)'
./Test.cpp:12:43: note: candidate is:
..\Squirrel/sqrat/sqrat/sqratClass.h:126:46: note: template<class V> Sqrat::Class& Sqrat::Class::Var(const SQChar*, V C::*) [with V = V, C = TestClass, A = Sqrat::
DefaultAllocator<TestClass>, Sqrat::Class<C, A> = Sqrat::Class<TestClass>, SQChar = char]


It's worth noting that above code compiles fine in Microsoft Visual C++ 2008, unofortunetly i need it on linux.

Is there any way to fix or workaround this?
atai
#2 Posted : Sunday, July 08, 2012 5:18:32 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 8/16/2005(UTC)
Posts: 287

Thanks: 14 times
Was thanked: 13 time(s) in 11 post(s)
What version of SQRat are you using?
Shikken
#3 Posted : Monday, July 09, 2012 9:05:59 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/27/2012(UTC)
Posts: 4
Location: Poland

Thanks: 1 times
Was thanked: 0 time(s) in 0 post(s)
0.8.2
atai
#4 Posted : Wednesday, July 11, 2012 6:59:50 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 8/16/2005(UTC)
Posts: 287

Thanks: 14 times
Was thanked: 13 time(s) in 11 post(s)
OK, with gcc 4.6.3 on Fedora 16 x86-64, the following code works

C++
Code:

class BaseClass
{
public:
    int baseVariable;
    void print()
    {
        printf("base var: %d\n", baseVariable);
    }
   
};

class TestClass : public BaseClass
{
public:
    int testVar;
    void print()
    {
        printf("test var: %d\n", testVar);
        BaseClass::print();
    }
};


static int bind(HSQUIRRELVM vm)
{

    Class<TestClass> testClass(vm);
    testClass.Var("testVar", &TestClass::testVar); // works

    testClass.Var("baseVariable", (int TestClass::*)&BaseClass::baseVariable); // works
   
    testClass.Func("print", &TestClass::print);

    RootTable(vm).Bind("TestClass", testClass);
       
    return 1;
}




Squirrel
Code:

local t =  TestClass();

t.baseVariable = 22;
t.testVar = 33;

t.print();


prints

Code:

[atai]$ ./test  t3.nut
test var: 33
base var: 22


Shikken wrote:
Hello,
i've come up with a problem recently

Code:
class BaseClass
{
public:
    int baseVariable;
};

class TestClass : public BaseClass
{
public:
    int testVar;
};

Class<TestClass> testClass(vm);
testClass.Var("testVar", &TestClass::testVar); // works
testClass.Var("baseVariable", &TestClass::baseVariable); // isn't working


The problem is that gcc is not accepting variables and functions from inherited classes, im using TDM-GCC 4.6.1-tdm64-1 and 4.7.1 on linux.
Gcc gives me this error while compiling:
Code:

error: no matching function for call to 'Sqrat::Class<TestClass>::Var(const char [13], int BaseClass::*)'
./Test.cpp:12:43: note: candidate is:
..\Squirrel/sqrat/sqrat/sqratClass.h:126:46: note: template<class V> Sqrat::Class& Sqrat::Class::Var(const SQChar*, V C::*) [with V = V, C = TestClass, A = Sqrat::
DefaultAllocator<TestClass>, Sqrat::Class<C, A> = Sqrat::Class<TestClass>, SQChar = char]


It's worth noting that above code compiles fine in Microsoft Visual C++ 2008, unofortunetly i need it on linux.

Is there any way to fix or workaround this?

Shikken
#5 Posted : Wednesday, July 11, 2012 8:34:45 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/27/2012(UTC)
Posts: 4
Location: Poland

Thanks: 1 times
Was thanked: 0 time(s) in 0 post(s)
It works! Thank you very much!
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.090 seconds.