BUG: function pointer as struct member does not compile if name is same as the struct
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Mon Jul 18 09:28:34 UTC 2022
Hi,
I can reproduce even with explicit struct name:
```
struct Foo {
int (*Foo)();
};
```
I'll leave this to Sundar - my feeling is that the code in Output helper
that handles function pointers does not check for clashes with the
surrounding scope; we perform such checks when nesting structs inside
other structs, but apparently the name clash logic is missing for
function pointers.
Maurizio
On 17/07/2022 04:28, Lost Illusion wrote:
> Hello,
> I'm currently using jextract in tandem with Kotlin/Native's ability to
> generate shared libraries and header files. It works nicely until you
> add a class to the Kotlin code which generates a struct and a function
> pointer (the initializer for the class) as a struct member, with both
> having the same name. Here's a minimal header file with the same
> problem.
> test.h:
> ```
> struct {
> int (*Foo)();
> } Foo;
> ```
> While this is valid for a header file, jextract has a problem
> processing it. Using the latest jextract on the jdk18 branch, and
> using the following command: `jextract test.h`. I get bombarded with
> 11 errors about resolving symbols and a duplicate class. Seems to be
> because a static class for the struct Foo is generated and an
> interface for the method Foo is also generated. I'm new to the project
> and not sure what the correct behavior should be in order to fix this
> issue.
More information about the jextract-dev
mailing list