Hi, as far as I have been able to gather, seqs are internally represented as a length and a pointer to a garbage collected memory area, which may be moved upon resize.
Is there a way to get the seq pointer to pass it to a C library? I was tempted to use addr, but I think it is not what I am after. If I understand correctly, addr(s) would be the pointer to the sequence itself (including the length field), but I need the pointer to the data
addr(s[0])
IMHO the compiler shouldn't be a nanny when it comes to the low level stuff. addr and cast are keywords that stick out for a reason and there are lots of cases where addr seq is what is required. Also note that some typing discipline helps:
proc takesCarray(x: ptr int) {.importc}
var s: seq[int]
takesCarray(addr s) # type mismatch
takesCarray(addr s[0]) # compiles