# How I create a Record type for a struct of voidpointers

**URL:** <https://numba.discourse.group/t/how-i-create-a-record-type-for-a-struct-of-voidpointers/2444>\
**Category:** Support: How do I do ...?\
**Created:** [March 4, 2024, 9:04am UTC](https://numba.discourse.group/t/how-i-create-a-record-type-for-a-struct-of-voidpointers/2444 "2024-03-04T09:04:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnhelt](https://avatars.discourse-cdn.com/v4/letter/j/2bfe46/32.png) [@johnhelt](https://numba.discourse.group/u/johnhelt)\
**Post date:** [March 4, 2024, 9:04am UTC](https://numba.discourse.group/t/how-i-create-a-record-type-for-a-struct-of-voidpointers/2444/1 "2024-03-04T09:04:08Z")

</div>

I am using numba to interface to a c-function library. One function requires me to pass in a struct containing a list of void-pointers to external function calls. I plan to implement my functions through numbas `cfunc` wrapper, as per the cfunc numba manual and call the function inside my jitted functions following the guide in the docs (“calling-c-code-from-numba”, sorry can’t post links for some reason).

To do this I need to implement the function signature.

Here’s what I thought I could do initially for my struct (fmi2CallbackFunctions\_numba:

```auto
from numba import types

fmi2CallbackFunctions_numba = types.Record.make_c_struct([
     ("logger", types.voidptr),
     ("allocateMemory", types.voidptr), 
     ...
])

```

The problem I am faced with is that numbas types.Record.make\_c\_struct does not support void pointers. So how can I extend that support of work around it?  
Hope to hear some good suggestions 🙂

---

<div class="post-metadata">

**Author:** ![nelson2005](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/nelson2005/32/47_2.png) [@nelson2005](https://numba.discourse.group/u/nelson2005)\
**Post date:** [March 4, 2024, 4:47pm UTC](https://numba.discourse.group/t/how-i-create-a-record-type-for-a-struct-of-voidpointers/2444/2 "2024-03-04T16:47:26Z")

</div>

Can you use integers and casting?

---

<div class="post-metadata">

**Author:** ![johnhelt](https://avatars.discourse-cdn.com/v4/letter/j/2bfe46/32.png) [@johnhelt](https://numba.discourse.group/u/johnhelt)\
**Post date:** [March 4, 2024, 9:04pm UTC](https://numba.discourse.group/t/how-i-create-a-record-type-for-a-struct-of-voidpointers/2444/3 "2024-03-04T21:04:07Z")

</div>

Hi, thanks for your reply. Are you asking me a question, or are you telling me I can do that? Can you give me an example? I didn’t find anything in the docs describing this particular case.

If I check ctypes, a void pointer typically takes up int64, so 8 bytes. But it seems llvm represents them by i8, so 1 byte. I’m not sure which one I should use in that case. Finally, how would the c wrapped function know that I’m passing it a pointer to a function, when I would be in fact, passing an integer?

Sorry for the questions, maybe it’s obvious if you’re a c programmer, but I’m just an engineer who’s trying to use numba to speed up calculations.

---

<div class="post-metadata">

**Author:** ![nelson2005](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/nelson2005/32/47_2.png) [@nelson2005](https://numba.discourse.group/u/nelson2005)\
**Post date:** [March 5, 2024, 12:30am UTC](https://numba.discourse.group/t/how-i-create-a-record-type-for-a-struct-of-voidpointers/2444/4 "2024-03-05T00:30:51Z")

</div>

You can do that. There are examples here on discourse, and [numbsql](https://github.com/cpcloud/numbsql) has some great examples.

---

<div class="post-metadata">

**Author:** ![johnhelt](https://avatars.discourse-cdn.com/v4/letter/j/2bfe46/32.png) [@johnhelt](https://numba.discourse.group/u/johnhelt)\
**Post date:** [March 5, 2024, 1:08pm UTC](https://numba.discourse.group/t/how-i-create-a-record-type-for-a-struct-of-voidpointers/2444/5 "2024-03-05T13:08:07Z")

</div>

Thanks again. I looked into the library, and there’s alot of @intrinsic calls, which seems to have very little documentation apart from one small example (but no explanations). Passing integers as addresses to pointers and then casting them as pointers did indeed occur to me as a possibility, that I’ve seen others apply as a work-around. Being what it is, a work-around, it occurs to me that this part of numba is fairly untouched. I’ll try to fiddle around and see what I can come up with.
