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

Printing struct with c alias map gives c compiler error: 'indent_struct' undeclared #22379

Closed
daansystems opened this issue Oct 1, 2024 · 3 comments · Fixed by #22381
Closed
Assignees
Labels
Auto str Method Generation Bugs/feature requests, that are related to the automatic string method generation. Bug This tag is applied to issues which reports bugs. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.

Comments

@daansystems
Copy link

daansystems commented Oct 1, 2024

V doctor:

V full version: V 0.4.8 18eee34.1b812f6
OS: windows, Microsoft Windows 11 Pro v22631 64-bit
Processor: 24 cpus, 64bit, little endian, 

getwd: D:\vbug2
vexe: C:\v\v.exe
vexe mtime: 2024-10-01 06:01:23

vroot: OK, value: C:\v
VMODULES: OK, value: C:\Users\info\.vmodules
VTMP: OK, value: C:\Users\info\AppData\Local\Temp\v_0

Git version: git version 2.42.0.windows.2
Git vroot status: 0.4.8-10-g1b812f6b-dirty
.git/config present: true

CC version: Error: 'cc' is not recognized as an internal or external command,

operable program or batch file.


thirdparty/tcc status: thirdparty-windows-amd64 b425ac82

What did you do?
./v -g -o vdbg cmd/v && ./vdbg main.v

module main

import sokol.gfx

struct GameObject  {
mut:
	shader_cache    map[string]gfx.Pipeline
}

fn main() {
	g := GameObject{}
	println(g)
}

What did you expect to see?

no c error

What did you see instead?

================== C compilation error (from tcc): ==============
cc: C:/v/thirdparty/sokol/sokol_app.h:7834: warning: implicit declaration of function 'freopen_s'
cc: C:/Users/info/AppData/Local/Temp/v_0/main.01J93DP44V8CYN34300JY0EJ37.tmp.c:2988: error: 'indent_struct' undeclared
... (the original output was 8 lines long, and was truncated to 2 lines)
=================================================================
(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 .

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.

@daansystems daansystems changed the title Printing struct with embeded map gives c compiler error: 'indent_struct' undeclared Printing struct with embedded map gives c compiler error: 'indent_struct' undeclared Oct 1, 2024
@esquerbatua esquerbatua changed the title Printing struct with embedded map gives c compiler error: 'indent_struct' undeclared Printing struct with c alias map gives c compiler error: 'indent_struct' undeclared Oct 1, 2024
@esquerbatua
Copy link
Contributor

It's more related to print a C alias of C.sgl_pipeline (pub type Pipeline = C.sgl_pipeline)

If you run a basic struct without a map of a C alias it works:

module main

struct GameObject  {
mut:
	shader_cache    map[string]int
}

fn main() {
	g := GameObject{}
	println(g)
}

result:

GameObject{
    shader_cache: {}
}

@esquerbatua esquerbatua added Nicer V Errors Bugs/feature requests, related to improving V error messages. and removed Nicer V Errors Bugs/feature requests, related to improving V error messages. labels Oct 1, 2024
@esquerbatua
Copy link
Contributor

Shouldn't fields that are aliases to C be printed?

@daansystems
Copy link
Author

module main

import sokol.gfx

struct GameObject  {
mut:
	shader_pipeline    gfx.Pipeline
}

fn main() {
	p := GameObject{}
	println(p)
}

prints correct:

GameObject{
    shader_pipeline:     sokol.gfx.Pipeline(C.sg_pipeline{
    id: 0
})
}

@esquerbatua esquerbatua added the Bug This tag is applied to issues which reports bugs. label Oct 1, 2024
@felipensp felipensp added Unit: cgen Bugs/feature requests, that are related to the default C generating backend. Auto str Method Generation Bugs/feature requests, that are related to the automatic string method generation. labels Oct 1, 2024
@felipensp felipensp self-assigned this Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto str Method Generation Bugs/feature requests, that are related to the automatic string method generation. Bug This tag is applied to issues which reports bugs. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants