Skip to content

Anonymous struct can not be selected by decl name "struct" #1026

@dschrempf

Description

@dschrempf

hs-bindgen offers selection by declaration name. For example, using the client option --select-by-decl-name. We also offer to select declarations by name kind (I am not sure if this is documented anywhere). For example, to select all structures, one can run

(C) $ cabal run -- hs-bindgen-cli preprocess -I ./ select-test.h --select-by-decl-name struct

Now, if select-test.h is

struct nested_outer_s {
  struct {
    int inner_member;
  } nested_inner_s;
};

We get an error:

[Error  ] [HsBindgen] [mangle-names] Missing declaration: 'struct nested_outer_s_nested_inner_s'; did you select the declaration?

This is because anonymous declarations are only matched against their name (prefixed with "anon:", which seems also pretty arbitrary). That is, we do not match against the name kind prefix.

In this case, the two strings we match against are:

"anon:nested_outer_s_nested_inner_s"
"struct nested_outer_s"

and only the second one gets selected. The first one is missing, as the error reports.

This may be a none-issue, but I think we should at least decide what we do in these cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageRequires triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions