How to initialize a cstruct that has an array?

Hi all,

I'd like to create a cstruct which has an array as one of its fields. For the sake of the example, let's say the array is an array of integers. When I try create a new instance of the cstruct, I don't know how to initialize the array field. Here is a simple example:

#lang racket

(require ffi/unsafe)
(define _args (make-array-type _uint64 4))
(define-cstruct _mystruct (
                         [id _uint8]
                         [flag _bool]
                         [args _args]))
 
(make-mystruct 123 #f #(1 2 3 4))

The error I get is this:

$ racket array.rkt
ptr-set!: given value does not fit primitive C type
  C type: (_array ....)
  given value: '#(1 2 3 4)
  context...:

It must be something simple that I am missing. Can somebody give me a hint?

Thx, -Diogo

You can use _array/vector:

#lang racket/base

(require ffi/unsafe)
(define-cstruct _mystruct (
                         [id _uint8]
                         [flag _bool]
                         [args (_array/vector _uint64 4)]))
 
(define s (make-mystruct 123 #f #(1 2 3 4)))
(println (vector-ref (mystruct-args s) 1))

There's also homogeneous numeric vectors, but I've never been able to get their type macros like _u64vector to work with the rest of the FFI.

Thank you! Works as expected.