Search code examples
rakunativecall

"Too many positionals passed" in NativeCall sub binding


I have this defined:

use NativeCall;

unit module kazmath;

class mat4 is repr('CStruct') {
    HAS num32 @.mat[16] is CArray;
}

sub kmMat4Fill( mat4 $mat, num32 @filler ) returns mat4 is native('kazmath')
                                            is export {*}

The function to bind is defined here:

kmMat4* kmMat4Fill(kmMat4* pOut, const kmScalar* pMat);

And the error returned is:

Too many positionals passed; expected 2 arguments but got 3

I really can't figure this out.


Solution

  • This is fixed with

    sub kmMat4Fill( mat4 $mat, CArray[num32] $filler )
            returns mat4 is native('kazmath') is export {*}
    

    Positionals can't be used in NativeCall, but still, the error message is LTA (Less Than Awesome).