Squirrel

The programming language
Welcome to Squirrel Sign in | Join | Help
in Search

is int * allowed as a parameter

Last post 05-24-2008, 11:16 AM by drac_gd. 2 replies.
Sort Posts: Previous Next
  •  05-24-2008, 12:37 AM 2528

    is int * allowed as a parameter

    I cannot use int * as a function parameter..

    here is my example test

     

    class VxTest

    {

    public:

    //=== constructor ===//

    VxTest(){};

    //=== destructor ===//

    virtual ~VxTest(){};

    //! initialize sound manager

    RCODE StartupVxTest( irr::VxIrrBase * poMgr );

    //! shutdown sound manager

    void ShutdownVxTest( void );

    //! play a sound 2d

    //! returns handle to sound stream

    virtual int PlaySound2d( const char * pFileName, // file name

    int bLooping=0, // if true loop continuous

    int * piRetSndChannel=0 );// return handle to sound source instance

    //! register sound object with squirrel scripting

    static void RegisterWithSquirrelScripting( void );

    };

    DECLARE_INSTANCE_TYPE(VxTest); // declare type for squirrel

    //! returns handle to sound stream

    int VxTest::PlaySound2d( const char * pFileName, // file name

    int bLooping, // if true loop continuous

    int * piRetSndChannel )// return handle to sound source instance

    {

    return 0;

    }

    //---------------------------------------------------------------------------

    //! register sound object with squirrel scripting

    void VxTest::RegisterWithSquirrelScripting( void )

    {

    // register squirrel interface

    SqPlus::SQClassDef<VxTest> ( _T("VxTest") ).

    func( &VxTest::PlaySound2d, _T("PlaySound2d") );

    }

    when I try to compile with visual studio 2008 I get

    DracIrrLibD.lib(VxSoundMgr.obj) : error LNK2019: unresolved external symbol "int * __cdecl SqPlus::Get<int>(struct SqPlus::TypeWrapper<int *>,struct SQVM *,int)" (??$Get@H@SqPlus@@YAPAHU?$TypeWrapper@PAH@0@PAUSQVM@@H@Z) referenced in function "public: static int __cdecl SqPlus::ReturnSpecialization<int>::Call<class VxTest,char const *,int,int *>(class VxTest &,int (__thiscall VxTest::*)(char const *,int,int *),struct SQVM *,int)" (??$Call@VVxTest@@PBDHPAH@?$ReturnSpecialization@H@SqPlus@@SAHAAVVxTest@@P82@AEHPBDHPAH@ZPAUSQVM@@H@Z)

    DracIrrLibD.lib(VxSoundMgr.obj) : error LNK2019: unresolved external symbol "bool __cdecl SqPlus::Match<int>(struct SqPlus::TypeWrapper<int *>,struct SQVM *,int)" (??$Match@H@SqPlus@@YA_NU?$TypeWrapper@PAH@0@PAUSQVM@@H@Z) referenced in function "public: static int __cdecl SqPlus::ReturnSpecialization<int>::Call<class VxTest,char const *,int,int *>(class VxTest &,int (__thiscall VxTest::*)(char const *,int,int *),struct SQVM *,int)" (??$Call@VVxTest@@PBDHPAH@?$ReturnSpecialization@H@SqPlus@@SAHAAVVxTest@@P82@AEHPBDHPAH@ZPAUSQVM@@H@Z)

    ../../../bin/win32/SlytronWorldBuilder.exe : fatal error LNK1120: 2 unresolved externals

     

    If I change

    virtual int PlaySound2d( const char * pFileName, int bLooping=0,  int * piRetSndChannel=0 )

    to

    virtual int PlaySound2d( const char * pFileName, int bLooping=0,  int piRetSndChannel=0 )

    then it compiles fine.

    Am I not allowed to use int pointers as parameters?

  •  05-24-2008, 3:36 AM 2531 in reply to 2528

    Re: is int * allowed as a parameter

    Hello,

    No, you cannot use a pointer to 'a primitive Squirrel type'.

    Pointers to instances are OK, but you could not change Squirrel variables themselves with a pointer in SqPlus.

    Looks like you'd have to break it up in two functions:

      int GetReturnSndChannel2d( filename, bLooping )
      int playSound2d( filename, bLooping )

    or something like that.

    Regards
    // ATS.
  •  05-24-2008, 11:16 AM 2535 in reply to 2531

    Re: is int * allowed as a parameter

     

    Thanks ats for the reply:)

    It should not be hard to work around this limitation:)

     

View as RSS news feed in XML
Powered by Community Server, by Telligent Systems