Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgen: invalid autogenerated eq functions #23472

Open
dy-tea opened this issue Jan 14, 2025 · 5 comments
Open

cgen: invalid autogenerated eq functions #23472

dy-tea opened this issue Jan 14, 2025 · 5 comments
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.

Comments

@dy-tea
Copy link

dy-tea commented Jan 14, 2025

Been having this issue in my project where uncompilable eq functions are being generated causing a failed compilation. Didn't open as a bug because I'm not sure if it's a bug or my fault (I haven't been able to reproduce with a smaller example).

Output snippet:

/tmp/v_1000/compositor.01JHKCE915BY6K8ESGDNF49457.tmp.c: In function ‘wlr_surface_state_struct_eq’:
/tmp/v_1000/compositor.01JHKCE915BY6K8ESGDNF49457.tmp.c:4400:56: error: incompatible type for argument 1 of ‘src__wlr___VAnonStruct18_struct_eq’
 4400 |                 && src__wlr___VAnonStruct18_struct_eq(a.viewport, b.viewport)
      |                                                       ~^~~~~~~~~
      |                                                        |
      |                                                        struct <anonymous>

My code can be found here, if anyone is interested in diagnosing the problem you can have a look. If this issue is invalid feel free to close it.

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Copy link

Connected to Huly®: V_0.6-21902

@felipensp
Copy link
Member

I'm getting builder error: Header file "wlr/util/addon.h", needed for module src.wlr was not found. Please install the corresponding development headers. when trying to build it.

@felipensp felipensp added Bug This tag is applied to issues which reports bugs. Unit: cgen Bugs/feature requests, that are related to the default C generating backend. labels Jan 15, 2025
@dy-tea
Copy link
Author

dy-tea commented Jan 15, 2025

Interesting, are you using the incorrect version of wlroots by any chance? My project builds against 0.19 but I haven't made it clear in the README so you might be using 0.18

@felipensp
Copy link
Member

This is because you are referencing the C anonymous struct type that is not same type than V created to represent it. To make it working we should cast it.

@felipensp
Copy link
Member

struct Foo {
    struct {
        int b;
    } a;
};
#include "@VROOT/foo.h"

struct C.Foo {
	a struct {
		b int
	}
}

fn main() {
	a := C.Foo{}
	b := C.Foo{}
	assert a == b
}
inline bool main___VAnonStruct1_struct_eq(main___VAnonStruct1 a, main___VAnonStruct1 b) {
	return a.b == b.b;
}

inline bool Foo_struct_eq(struct Foo a, struct Foo b) {
	return main___VAnonStruct1_struct_eq(a.a, b.a);
}

Foo.a is not main___VAnonStruct1. But it could be casted to it.

@felipensp felipensp added the Status: Confirmed This bug has been confirmed to be valid by a contributor. label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.
Projects
None yet
Development

No branches or pull requests

2 participants