Sq Plus MSVC71 Compiler Problem
Last changed: -87.248.160.134

.

alvarbase

Microsoft C++ compiler v7.1 fails to compile following code

class Base {
public:
  void test() { 
    printf("test() called\n"); 
  }
};

class Derived : public Base {
  void dummyToKeepCompiledFromMergingClasses() { 
    printf("something\n");
  }
};

DECLARE_INSTANCE_TYPE(Derived)

int main()
{
  SqPlus::SQClassDef<Derived>("Derived")
//    .func(&Base::test, "test")
    .func(&Derived::test, "test")
  ;
  return 0;
}

When trying to compile it prints the following output

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (__thiscall Callee::* )(P1,P2,P3,P4,P5,P6,P7) const,HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (__thiscall Derived::* )(T3,T4,T5,T6,T7,T8,T9) const' from 'void (__thiscall Base::* )(void)'
        c:\engine\prog\3rdPartyLibs\scripts\Squirrel\sqplus\SqPlusConst.h(296) : see declaration of 'SqPlus::Call'
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1232) : while compiling class-template member function 'int SqPlus::DirectCallInstanceMemberFunction<Callee,Func>::Dispatch(HSQUIRRELVM)'
        with
        [
            Callee=Derived,
            Func=void (__thiscall Base::* )(void)
        ]
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1314) : see reference to class template instantiation 'SqPlus::DirectCallInstanceMemberFunction<Callee,Func>' being compiled
        with
        [
            Callee=Derived,
            Func=void (__thiscall Base::* )(void)
        ]
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1398) : see reference to function template instantiation 'void SqPlus::sq_pushdirectinstanceclosure<Callee,Func>(HSQUIRRELVM,const Callee &,Func,SQUnsignedInteger)' being compiled
        with
        [
            Callee=Derived,
            Func=void (__thiscall Base::* )(void)
        ]
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1756) : see reference to function template instantiation 'void SqPlus::RegisterInstance<TClassType,Func>(HSQUIRRELVM,HSQOBJECT,Callee &,Func,const SQChar *)' being compiled
        with
        [
            TClassType=Derived,
            Func=void (__thiscall Base::* )(void),
            Callee=Derived
        ]
        ..\..\..\..\prog\tools\test\SquirrelTest\ClassTest.cpp(233) : see reference to function template instantiation 'SqPlus::SQClassDef<TClassType> &SqPlus::SQClassDef<TClassType>::func<void(__thiscall Base::* )(void)>(Func,const SQChar *)' being compiled
        with
        [
            TClassType=Derived,
            Func=void (__thiscall Base::* )(void)
        ]
../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (__thiscall Callee::* )(P1,P2,P3,P4,P5,P6) const,HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (__thiscall Derived::* )(T3,T4,T5,T6,T7,T8) const' from 'void (__thiscall Base::* )(void)'
        c:\engine\prog\3rdPartyLibs\scripts\Squirrel\sqplus\SqPlusConst.h(291) : see declaration of 'SqPlus::Call'
../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (__thiscall Callee::* )(P1,P2,P3,P4,P5) const,HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (__thiscall Derived::* )(T3,T4,T5,T6,T7) const' from 'void (__thiscall Base::* )(void)'
        c:\engine\prog\3rdPartyLibs\scripts\Squirrel\sqplus\SqPlusConst.h(286) : see declaration of 'SqPlus::Call'
../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (__thiscall Callee::* )(P1,P2,P3,P4) const,HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (__thiscall Derived::* )(T3,T4,T5,T6) const' from 'void (__thiscall Base::* )(void)'
        c:\engine\prog\3rdPartyLibs\scripts\Squirrel\sqplus\SqPlusConst.h(281) : see declaration of 'SqPlus::Call'
../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (__thiscall Callee::* )(P1,P2,P3) const,HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (__thiscall Derived::* )(T3,T4,T5) const' from 'void (__thiscall Base::* )(void)'
        c:\engine\prog\3rdPartyLibs\scripts\Squirrel\sqplus\SqPlusConst.h(276) : see declaration of 'SqPlus::Call'
../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (__thiscall Callee::* )(P1,P2) const,HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (__thiscall Derived::* )(T3,T4) const' from 'void (__thiscall Base::* )(void)'
        c:\engine\prog\3rdPartyLibs\scripts\Squirrel\sqplus\SqPlusConst.h(271) : see declaration of 'SqPlus::Call'
../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (__thiscall Callee::* )(P1) const,HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (__thiscall Derived::* )(T3) const' from 'void (__thiscall Base::* )(void)'
        c:\engine\prog\3rdPartyLibs\scripts\Squirrel\sqplus\SqPlusConst.h(266) : see declaration of 'SqPlus::Call'
../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (__thiscall Callee::* )(void) const,HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (__thiscall Derived::* )(void) const' from 'void (__thiscall Base::* )(void)'
        c:\engine\prog\3rdPartyLibs\scripts\Squirrel\sqplus\SqPlusConst.h(261) : see declaration of 'SqPlus::Call'
../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (__thiscall Callee::* )(P1,P2,P3,P4,P5,P6,P7),HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (__thiscall Derived::* )(T3,T4,T5,T6,T7,T8,T9)' from 'void (__thiscall Base::* )(void)'
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1190) : see declaration of 'SqPlus::Call'
../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (__thiscall Callee::* )(P1,P2,P3,P4,P5,P6),HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (__thiscall Derived::* )(T3,T4,T5,T6,T7,T8)' from 'void (__thiscall Base::* )(void)'
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1185) : see declaration of 'SqPlus::Call'
../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (__thiscall Callee::* )(P1,P2,P3,P4,P5),HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (__thiscall Derived::* )(T3,T4,T5,T6,T7)' from 'void (__thiscall Base::* )(void)'
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1180) : see declaration of 'SqPlus::Call'
../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (__thiscall Callee::* )(P1,P2,P3,P4),HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (__thiscall Derived::* )(T3,T4,T5,T6)' from 'void (__thiscall Base::* )(void)'
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1175) : see declaration of 'SqPlus::Call'
../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (__thiscall Callee::* )(P1,P2,P3),HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (__thiscall Derived::* )(T3,T4,T5)' from 'void (__thiscall Base::* )(void)'
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1170) : see declaration of 'SqPlus::Call'
../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (__thiscall Callee::* )(P1,P2),HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (__thiscall Derived::* )(T3,T4)' from 'void (__thiscall Base::* )(void)'
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1165) : see declaration of 'SqPlus::Call'
../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (__thiscall Callee::* )(P1),HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (__thiscall Derived::* )(T3)' from 'void (__thiscall Base::* )(void)'
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1160) : see declaration of 'SqPlus::Call'
../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (__thiscall Callee::* )(void),HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (__thiscall Derived::* )(void)' from 'void (__thiscall Base::* )(void)'
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1155) : see declaration of 'SqPlus::Call'
../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2780: 'int SqPlus::Call(RT (__fastcall *)(P1,P2,P3,P4,P5,P6,P7),HSQUIRRELVM,int)' : expects 3 arguments - 4 provided
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1148) : see declaration of 'SqPlus::Call'
../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2780: 'int SqPlus::Call(RT (__fastcall *)(P1,P2,P3,P4,P5,P6),HSQUIRRELVM,int)' : expects 3 arguments - 4 provided
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1143) : see declaration of 'SqPlus::Call'
../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2780: 'int SqPlus::Call(RT (__fastcall *)(P1,P2,P3,P4,P5),HSQUIRRELVM,int)' : expects 3 arguments - 4 provided
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1138) : see declaration of 'SqPlus::Call'
../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2780: 'int SqPlus::Call(RT (__fastcall *)(P1,P2,P3,P4),HSQUIRRELVM,int)' : expects 3 arguments - 4 provided
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1133) : see declaration of 'SqPlus::Call'
../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2780: 'int SqPlus::Call(RT (__fastcall *)(P1,P2,P3),HSQUIRRELVM,int)' : expects 3 arguments - 4 provided
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1128) : see declaration of 'SqPlus::Call'
../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2780: 'int SqPlus::Call(RT (__fastcall *)(P1,P2),HSQUIRRELVM,int)' : expects 3 arguments - 4 provided
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1123) : see declaration of 'SqPlus::Call'
../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2780: 'int SqPlus::Call(RT (__fastcall *)(P1),HSQUIRRELVM,int)' : expects 3 arguments - 4 provided
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1118) : see declaration of 'SqPlus::Call'
../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2780: 'int SqPlus::Call(RT (__fastcall *)(void),HSQUIRRELVM,int)' : expects 3 arguments - 4 provided
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1113) : see declaration of 'SqPlus::Call'
Solution

Create a typedef and cast as shown below:

class Base {
public:
  void test(void) { 
    printf("test() called\n"); 
  }
};

class Derived : public Base {
  void dummyToKeepCompiledFromMergingClasses() { 
    printf("something\n");
  }
};

DECLARE_INSTANCE_TYPE(Derived);

typedef void (Derived::*DerivedTestFunc)(void);

int testDerived() {
  SqPlus::SQClassDef<Derived>("Derived")
    .func((DerivedTestFunc)&Derived::test, "test");
  return 0;
}