Julia is a fixed-size array in structure C

I need to create a Julia type corresponding to a C structure that has a fixed size array:

struct cstruct {
    ...
    int arr[N] //N known at compile time
    ...
};

I defined Julia types corresponding to other C-structures with such arrays:

type  jstruct
    ...
    arr::Ptr{Cint}
    ...
end

But, as I understand it, this only works when it arris a pointer, not an array of a certain size. How can I guarantee that the offsets of the elements following follow arrremain unchanged in both languages?

+4
source share
2 answers

C ( ), . . :

type JStruct{N}
    arr::NTuple{N,Int}
end

.

+6

, Julia, StaticArrays. , AbstractArray.

+2

Source: https://habr.com/ru/post/1659417/


All Articles