Skip to content

Struct forward declarations cause fields to not populate #229

@ryan-thurber

Description

@ryan-thurber

In instances where forward declarations are required for structs, such as circular references, the python type slots and fields are not populated for the forward declared struct.

Simple example:

//header.h
typedef struct B B;

typedef struct A
{
    B *bptr;
}A;

typedef struct B
{
    A *aptr;
}B;

ctypesgen generates:

# header.h: 2
class struct_B(Structure):
    pass 

B = struct_B# header.h: 2 

# header.h: 7
class struct_A(Structure):
    pass

struct_A.__slots__ = [
    'bptr',
]

struct_A._fields_ = [
    ('bptr', POINTER(B)),
]

A = struct_A# header.h: 7
B = struct_B# header.h: 2
A = struct_A# header.h: 7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions