Skip to content

Manipulating C pointers #546

@certik

Description

@certik

Here is an example of how pointers should be manipulated, in Fortran, Python, both should generate the same ASR, and the C backend should then generate the output below:

Fortran:

type(c_ptr) :: queries
integer(2), pointer :: x(:)         
c_f_pointer(queries, x)
c_loc(x(idx))       

Python:

from ltypes import c_loc, c_p_pointer, CPtr, Pointer
from typing import Annotate
queries: CPtr
x: Annotate[i16[:], Pointer]
x = c_p_pointer(queries, i16)                      
c_loc(x[idx])           

C output:

void *queries;
int16_t *x;
x = (int16_t*)queries;
&x[idx];

Also allow passing void * pointers as arguments to functions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions