1

I am trying to compile a program that binds a class so that I can use it with a squirrel script.

I am using VS2010 under Windows 7 and have compiled the squirrel libraries and sqrat using the unicode character set with debug configuration.

The error I get is in \sqrat\sqratclass.h, line 81:

error C2664: 'Sqrat::Class<C>::InitClass' : cannot convert parameter 1 from 'const char *' to 'const Sqrat::string &'   

does anybody know what I have to do to get this working properly? Or is this a bug in sqrat? Thank you very much!

This is the c++ file:

#include <iostream>
#include <string>
#include <sqrat.h>

class TestClass
{
public:
    int integerVar;
    std::wstring stringVar;
    void printString() { std::wcout << this->stringVar; }
};

void squirrelPrint(SQChar * text)
{
    std::wcout << text << std::endl;
}

int main()
{
    HSQUIRRELVM squirrelvm = sq_open(1024);
    Sqrat::DefaultVM::Set(squirrelvm);

    Sqrat::RootTable().Bind(L"TestClass", Sqrat::Class<TestClass>()
        .Func(L"printString", &TestClass::printString)
        .Var(L"integerVar", &TestClass::integerVar)
        .Var(L"strVar", &TestClass::stringVar));

    Sqrat::Script script;
    script.CompileFile(L"testfile.nut");
    script.Run();

}

EDIT: The line that gives the error is:

InitClass(typeid(*this).name());
Nakilon
  • 34,866
  • 14
  • 107
  • 142
Alex
  • 458
  • 5
  • 17
  • It would help if you specified more clearly which line gives error, since there's no line 81 here... And you are not showing \sqrat\sqratclass.h and/or sqrat.h code – Antonio Jul 07 '13 at 20:38
  • @Antonio the line that gives the error is InitClass(typeid(*this).name()); – Alex Jul 07 '13 at 20:43
  • Also, if it helps I am using sqrat 0.8.90 and squirrel 3.0.4 – Alex Jul 07 '13 at 20:44
  • Hmmm I would say that one of the parameters that you are passing has to be changed, it seems that `Sqrat::string` (of which you should check the constructor) is not going to accept a char*, or there is no conversion defined from char* to Sqrat::string, maybe using the "L" in front of the string is not helping – Antonio Jul 07 '13 at 20:54
  • @Antonio it gives another error, when I remove the 'L'. Anyways, thanks for helping! The author has fixed this in his latest version of sqrat – Alex Jul 07 '13 at 21:03

1 Answers1

1

I'm sorry, I should have tried this before asking the question here. I downloaded version 0.8.9 which is the "latest version" of sqrat, as it says on their homepage. It's probably the latest stable version.

Anyways, I've now tried the exact same thing using sqrat from https://github.com/Amorph/sqrat/ and it worked! Except I had to change this line

return sq_throwerror(vm, "No overload matching this argument list found");

into

return sq_throwerror(vm, _SC("No overload matching this argument list found"));
Alex
  • 458
  • 5
  • 17