# Passing array of pointers cfunc

**URL:** <https://numba.discourse.group/t/passing-array-of-pointers-cfunc/661>\
**Category:** Community Support\
**Created:** [April 8, 2021, 11:34am UTC](https://numba.discourse.group/t/passing-array-of-pointers-cfunc/661 "2021-04-08T11:34:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![majra20](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/majra20/32/296_2.png) [@majra20](https://numba.discourse.group/u/majra20)\
**Post date:** [April 8, 2021, 11:34am UTC](https://numba.discourse.group/t/passing-array-of-pointers-cfunc/661/1 "2021-04-08T11:34:14Z")

</div>

Hello,  
I have a function which as an argument takes:

- pointer to a list of pointers
- types of this pointers
- number of pointers

I would like to do sth like:

```
@cfunc(types.void(types.CPointer(types.int64), types.CPointer(types.int64), types.int64), nopython=True)
def foo(l, types_ptr, num):
    l_arr = carray(l, num)
    types = carray(types_ptr, num)
    for ptr, type in zip(l_arr, types):
        x = carray(ptr, SIZE, dtype=type) # can't be done because ptr is actually an int.

```

I would like to cast this int64 ptr to c\_void\_p or sth like that.

---

<div class="post-metadata">

**Author:** ![stuartarchibald](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/stuartarchibald/32/10_2.png) [@stuartarchibald](https://numba.discourse.group/u/stuartarchibald)\
**Post date:** [April 8, 2021, 12:03pm UTC](https://numba.discourse.group/t/passing-array-of-pointers-cfunc/661/2 "2021-04-08T12:03:39Z")

</div>

Hi @majra20

The “cast int to pointer” issue can be resolved with a function like:

```auto
from numba.extending import intrinsic
from llvmlite import ir
voidptr_t = ir.IntType(8).as_pointer()
@intrinsic
def asvoidp(tyctx, thing):
    sig = types.voidptr(thing)
    def codegen(cgctx, builder, sig, args):
        return builder.inttoptr(args[0], voidptr_t)
    return sig, codegen

```

and call it like

```auto
true_ptr = asvoidp(some_int)

```

Even with this added I don’t think the above will be something that can be compiled as the type of `x` cannot be known at compile time from the information currently provided.

Hope this helps?
