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 error when using sdl.Window as non-ref type for struct field #23042

Open
larpon opened this issue Dec 1, 2024 · 1 comment
Open

cgen error when using sdl.Window as non-ref type for struct field #23042

larpon opened this issue Dec 1, 2024 · 1 comment
Assignees
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. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general.

Comments

@larpon
Copy link
Contributor

larpon commented Dec 1, 2024

Describe the bug

================== C compilation error (from tcc): ==============
cc: /dev/shm/game.01JE1YPA1FWTHP3P6W2A0YMSBY.tmp.c:2549: error: field 'sdl_window' has incomplete type
=================================================================
(You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).

Reproduction Steps

This code with vlang/sdl 2.30.0 branch checked out in ~/.vmodules/sdl

import sdl

pub struct Window {
	sdl_window sdl.Window
}

fn main() {}

Expected Behavior

run + clean exit

Current Behavior

================== C compilation error (from tcc): ==============
cc: /dev/shm/game.01JE1Z9SGZT7BQ4S2NKTXZX233.tmp.c:2455: error: field 'sdl_window' has incomplete type
=================================================================
(You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).
builder error: 
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .

Possible Solution

Some of this could maybe be prevented in vlang/sdl via attributes - but I think the C error should not happen.

Additional Information/Context

SDL2 v 2.30.0

V version

V 0.4.8 40dc775

Environment details (OS name and version, etc.)

EndeavourOS. Arch-based, rolling distro

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.

Huly®: V_0.6-21482

@larpon larpon added Bug This tag is applied to issues which reports bugs. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general. 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. labels Dec 1, 2024
@larpon
Copy link
Contributor Author

larpon commented Dec 1, 2024

It has been discussed that maybe tagging such C constructs (opaque types) in V via @[opaque] and then giving checker error if it is not a pointer used could be a solution.

See discussion starting here: https://discord.com/channels/592103645835821068/592294828432424960/1312883921414914181

@spytheman spytheman self-assigned this Dec 2, 2024
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. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general.
Projects
None yet
Development

No branches or pull requests

2 participants