Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to access elements of pointer array in Nim?

I’ve been stuck on this

    
let aiArray: ptr aiMesh =  sceneptr[].mMeshes[]
# Here aiArray is a pointer to an array(from C), how can i access the elements like aiArray[0], aiArray[1] and stuff

I tried doing the aiArray[0] thing but didn’t work, I also tried to assign it to array[0..0, aiMesh] = sceneptr[].mMeshes[] but won’t work Either.

Also how does C like pointer arrays work in nim, I am really confused about this. Please help.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

cast[ptr UncheckedArray[aiMesh]](myPtr)[0]

Nim does not treat all pointers as indexable by default so you need to cast to an indexable ptr UncheckedArray or write the bindings as such.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading