Skip to content

Structures with typedef #7

@integerfn

Description

@integerfn

Hi! Thanks for the tremendous work. I've been looking for something like this for a long time.

I'm just getting started and trying to get the hang of it. The first issue I encountered which I have not been able to solve is related to structures defined with typedef. I have a mixed C/C++ codebase and we have several structs typedef'd like this:

typedef struct {
    int x;
} MyStruct ;

From what I have seen, litgen ignores these type definitions. Also tried using and got a similar results. Is there a configuration I need to enable to have type aliases included? I'm working with cppimport, but as far as I can tell the binding code is already missing for these types so I don't think that makes a difference.

Here's a simple example:

typedef struct {
    int x;
    int y;
} Vector2D;

int VectorNorm2( Vector2D v )
{
    return v.x * v.x + v.y * v.y;
}

This produces something that is missing the type definition

# stub
def vector_norm2(v: Vector2D) -> int:
    pass

// pydef
m.def("vector_norm2",
    VectorNorm2, py::arg("v"));

Any help is appreciated
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions