How to declare native array of fixed size in Perl 6?

  • A+

I'm am trying to declare the following C struct in Perl 6:

struct myStruct {     int A[2]; //<---NEED to declare this     int B;     int C; }; 

My problem is that I don't know how to declare the int A[2]; part using the built in NativeCall api.

So for what I have is:

class myStruct is repr('CStruct') {     has CArray[int32] $.A;     has int32 $.B;     has int32 $.C; }; 

However, I know that the has CArray[int32] $.A; part is wrong as it does not declare a part in my struct that takes up ONLY 2 int32 sizes.


See Declaring an array inside a Perl 6 NativeCall CStruct

There are other ways, but the easiest is instead of an array, just declare each individual item.

class myStruct is repr('CStruct') {     has int32 $.A0;     has int32 $.A1;     ... as many items as you need for your array ...     has int32 $.B;     has int32 $.C; }; 


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: