Skip to content

Struct initialization in global variable emits invalid C# #503

Description

@jwosty

C header:

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

Point MyGlobalPoint = { .x = 10, .y = 20 };

produces these C# bindings (missing the end curly brace on MyGlobalPoint):

namespace LibFoo.Interop
{
    public partial struct Point
    {
        public int x;

        public int y;
    }

    public static partial class NativeMethods
    {
        [NativeTypeName("struct Point")]
        public static Point MyGlobalPoint = new Point
        {
            x = 10,
            y = 20,
    }
}

It works fine for const struct Point MyConstPoint = { .x = 10, .y = 20 };

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