Simple, fast, safe, compiled language for developing maintainable software. Compiles itself in <1s with zero library dependencies. Supports automatic C => V translation. https://vlang.io
MIT License
35.86k
stars
2.17k
forks
source link
Instantiating struct with global on heap causes c error: expected struct or union but not 'struct main__GameObject *' #22970
V full version: V 0.4.8 5c65e58.9300982
OS: windows, Microsoft Windows 11 Pro v22631 64-bit
Processor: 24 cpus, 64bit, little endian,
get_current_dir: D:\vbug
vexe: C:\v\v.exe
vexe mtime: 2024-11-25 10:39:04
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: weekly.2024.47-35-g93009823-dirty
.git/config present: true
CC version: Error: 'cc' is not recognized as an internal or external command,
operable program or batch file.
emcc version: Error: 'emcc' 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 src/main.v
module main
@[heap]
struct Game {
mut:
object_id u32
}
__global (
g Game
)
@[heap]
struct GameObject {
mut:
id int = g.object_id++
}
fn main() {
mut g := GameObject{}
eprintln("G=${g}")
}
What did you expect to see?
no c error
What did you see instead?
$ /c/v/v -enable-globals run .
================== C compilation error (from tcc): ==============
cc: C:/Users/info/AppData/Local/Temp/v_0/vbug.01JDHEFNZ9FK39SECZ12MT17SW.tmp.c:7194: warning: implicit declaration of function 'tcc_backtrace'
cc: C:/Users/info/AppData/Local/Temp/v_0/vbug.01JDHEFNZ9FK39SECZ12MT17SW.tmp.c:13895: error: expected struct or union but not 'struct main__GameObject *'
... (the original output was 3 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.
V doctor:
What did you do?
./v -g -o vdbg cmd/v && ./vdbg src/main.v
What did you expect to see?
no c error
What did you see instead?
Huly®: V_0.6-21411