Skip to content

Why is NTuple generated for typedefs involving arrays? #284

Answered by Gnimuc
vrzh asked this question in Q&A
Discussion options

You must be logged in to vote

In this case I am trying to understand why mytype results in an immutable NTuple being generated?

I am wondering what C code the first translate function would correspond to?

If mytype is used as a type of a field member of a struct, it has to be a stack-allocated NTuple. If not, the layout of that struct will be incompatible with the one in C.

array function arguments should decay to pointers
e.g. double f[3] => Ptr{Cdouble} instead of NTuple{3, Cdouble}

In C, using const array type as function parameter types does not add any special restriction(e.g. the size) than a naive pointer type, the C compiler just does the decay implicitly, so here we do the same thing in Julia.

With the…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@vrzh
Comment options

@Gnimuc
Comment options

@Gnimuc
Comment options

@vrzh
Comment options

Answer selected by vrzh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants