================== C compilation error (from cc): ==============
cc: /tmp/v_501/linked-list.01K92CSBFFER0365V8M5Y8VXYN.tmp.c:1686:37: error: variable has incomplete type 'mapnode' (aka 'struct mapnode')
cc: 1686 | return ((mapnode*)builtin__memdup(&(mapnode){.children = ((void*)0),.len = 0,.keys = {(string){.str=(byteptr)"", .is_lit=1}, (string){.str=(byteptr)"", .is_lit=1}, (string){.str=(byteptr)"", .is_lit=1}, (string){.str=(byteptr)"", .is_lit=1}, (string){.str=(byteptr)"", .is_lit=1}, (string){.str=(byteptr)"", .is_lit=1}, (string){.str=(byteptr)"", .is_lit=1}, (string){.str=(byteptr)"", .is_lit=1}, (string){.str=(byteptr)"", .is_lit=1}, (string){.str=(byteptr)"", .is_lit=1}, (string){.str=(byteptr)"", .is_lit=1}},.values = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}, sizeof(mapnode)));
cc: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc: /tmp/v_501/linked-list.01K92CSBFFER0365V8M5Y8VXYN.tmp.c:32:16: note: forward declaration of 'struct mapnode'
cc: 32 | typedef struct mapnode mapnode;
cc: | ^
cc: /tmp/v_501/linked-list.01K92CSBFFER0365V8M5Y8VXYN.tmp.c:1686:564: error: invalid application of 'sizeof' to an incomplete type 'mapnode' (aka 'struct mapnode')
cc: 1686 | return ((mapnode*)builtin__memdup(&(mapnode){.children = ((void*)0),.len = 0,.keys = {(string){.str=(byteptr)"", .is_lit=1}, (string){.str=(byteptr)"", .is_lit=1}, (string){.str=(byteptr)"", .is_lit=1}, (string){.str=(byteptr)"", .is_lit=1}, (string){.str=(byteptr)"", .is_lit=1}, (string){.str=(byteptr)"", .is_lit=1}, (string){.str=(byteptr)"", .is_lit=1}, (string){.str=(byteptr)"", .is_lit=1}, (string){.str=(byteptr)"", .is_lit=1}, (string){.str=(byteptr)"", .is_lit=1}, (string){.str=(byteptr)"", .is_lit=1}},.values = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}, sizeof(mapnode)));
cc: | ^ ~~~~~~~~~
cc: /tmp/v_501/linked-list.01K92CSBFFER0365V8M5Y8VXYN.tmp.c:32:16: note: forward declaration of 'struct mapnode'
cc: 32 | typedef struct mapnode mapnode;
cc: | ^
cc: 2 errors generated.
================================================================
(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 .
Hello, I'm a beginner in Vlang. While training with exercises I stumble upon a weird bug: I should be able to instanciate my struct LinkedList and use struct methods on it but I get a cc compilation error. Do you have an idea of what I'm doing wrong ?
Thanks for your help :)
struct Node {
mut:
value int
prev ?&Node
next ?&Node
}
struct LinkedList {
mut:
length int
head ?&Node
}
pub fn (mut l LinkedList) push(value int) {
mut new_node := &Node{value: value}
if mut head := l.head {
for head.next != none {
if mut head_next := head.next {
head = head_next
}
}
head.next = new_node
new_node.prev = head
} else {
l.head = new_node
}
return
}
V version: V 0.4.12, press to see full `v doctor` output
What did you do?
./v -g -o vdbg cmd/v && ./vdbg linked-list.v && linked-listSee attached file
linked-list.vWhat did you see?
What did you expect to see?
Hello, I'm a beginner in Vlang. While training with exercises I stumble upon a weird bug: I should be able to instanciate my struct LinkedList and use struct methods on it but I get a cc compilation error. Do you have an idea of what I'm doing wrong ?
Thanks for your help :)
Code used
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.